[Scons-users] bypass string interpolation (quoting)

Jason Kenny dragon512 at live.com
Fri Jun 10 15:56:55 EDT 2016


This was a pain for myself as well.
This is code snipped of what I have Parts doing... from
https://bitbucket.org/sconsparts/parts/src/3a389f774f234694994071d784af88c3b
abaad03/parts/functors.py?at=master&fileviewer=file-view-default#functors.py
-91 

            rlst.append(self.env.Literal('{0}$$ORIGIN/{1}{0}'.format(quote,
self.env.Dir('$INSTALL_BIN').rel_path(
                                self.env.Dir('$INSTALL_LIB')))))
            self.env['RPATH']=rlst

I have these functors that get called in Parts and set the RPATH depending
on some settings. I basically added all the paths to a list and at that to
RPATH. Anything else failed...

This looks like what you are trying to do below for the solution you had
found.


You might want to open a bug on the this issue as it seems to be a bug in
the subst() code, that has an easy reproducer.

Jason


-----Original Message-----
From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Neal
Becker
Sent: Friday, June 10, 2016 2:17 PM
To: scons-users at scons.org
Subject: Re: [Scons-users] bypass string interpolation (quoting)

following this example:

ttps://stackoverflow.com/questions/7159612/scons-prevent-text-expansion-in-
construction-variable

I found this solution:
env['RPATH'] = [NDARRAYLIBPATH, BOOSTLIBPATH, PYTHON_LIBDIR, Literal('\'' +
':'.join(['$$ORIGIN/' + x for x in MKLPATH.split(':')]) + '\'')]

Note that directly setting this using Environment (RPATH = ...) doesn't
work, giving an error message:

scons: *** [mkl.cpython-35m-x86_64-linux-gnu.so] TypeError `__str__ returned
non-string (type generator)' trying to evaluate `${_concat(RPATHPREFIX,
RPATH, RPATHSUFFIX, __env__)}'

The quoting situation is pretty ugly IMO

Neal Becker wrote:

> Thinking that maybe I need to just use Literal, I tried:
> 
> MKLRPATH = [Literal(r'$ORIGIN/' + x for x in MKLPATH.split(':'))]
> 
> then setting:
> Envirnonment(...
>  RPATH=[NDARRAYLIBPATH, BOOSTLIBPATH, MKLRPATH , PYTHON_LIBDIR])
> 
> gives:
> scons: *** [mkl.cpython-35m-x86_64-linux-gnu.so] TypeError `__str__ 
> returned non-string (type generator)' trying to evaluate 
> `${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
> 
> Jason Kenny wrote:
> 
>> Hi,
>> 
>> I set this value in Parts via using env.Literal()
>> 
>> This should allow the value to be left untouched by SCons subst() engine.
>> 
>> Jason
>> 
>> -----Original Message-----
>> From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of 
>> Neal Becker
>> Sent: Friday, June 10, 2016 1:20 PM
>> To: scons-users at scons.org
>> Subject: [Scons-users] bypass string interpolation (quoting)
>> 
>> I need an environment containing
>> RPATH=[MKLPATH])
>> 
>> where MKLPATH = '$ORIGIN/...'
>> 
>> currently scons chokes on this, because it tries to expand 
>> (interpolate) the $ORIGIN.  I can't figure out how to quote this to 
>> bypass the expansion.
>> 
>> 
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
> 
> 
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users


_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://pairlist4.pair.net/mailman/listinfo/scons-users


More information about the Scons-users mailing list