Re: Should PseudoBuilder's get access to OverrideEnvironment values if called via one
"Andrew C. Morrow" <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <CA+Acj4dtSS_kMxnRZ69+FF-pOFm4qc++vaj1TGck+OE88CahUQ@mail.gmail.com> |
Did an issue ever get filed for this? I took a quick look in the issue tracker and didn't see anything that was obviously this. Thanks, Andrew On Fri, Apr 26, 2019 at 10:35 AM Gary Oberbrunner <[email protected]> wrote: > Not much, but they've been there since olden days. Check 1be774d48 from > Sept 2001: > > diff --git a/src/scons/Environment.py b/src/scons/Environment.py > index da71ba1..9b050d1 100644 > --- a/src/scons/Environment.py > +++ b/src/scons/Environment.py > @@ -62,8 +62,25 @@ class Environment: > import scons.Defaults > kw['BUILDERS'] = scons.Defaults.Builders[:] > self.Dictionary.update(copy.deepcopy(kw)) > + > + class BuilderWrapper: > + """Wrapper class that allows an environment to > + be associated with a Builder at instantiation. > + """ > + def __init__(self, env, builder): > + self.env = env > + self.builder = builder > + > + def __call__(self, target = None, source = None): > + return self.builder(self.env, target, source) > + > + def execute(self, **kw): > + apply(self.builder.execute, (), kw) > + > ... > > On Fri, Apr 26, 2019 at 10:25 AM Bill Deegan <[email protected]> > wrote: > >> I'll go ahead and file a bug. >> Do you know any of the history of >> >> MethodWrapper/BuilderWrapper >> >> -Bill >> >> On Fri, Apr 26, 2019 at 10:21 AM Gary Oberbrunner <[email protected]> >> wrote: >> >>> I agree with you -- it definitely should get the env it's called from no >>> matter if it's an OverrideEnvironment or a normal one. >>> >>> On Thu, Apr 25, 2019 at 10:14 PM Bill Deegan <[email protected]> >>> wrote: >>> >>>> Indeed it shoud. >>>> repo updated. >>>> Here's fixed example: >>>> >>>> from SCons.Environment import OverrideEnvironment >>>> >>>> DefaultEnvironment(tools=[]) >>>> env=Environment(BIN='mybin',LOCALBIN='localbin') >>>> >>>> def install_in_bin_dirs(env, source): >>>> """Install source in both bin dirs""" >>>> i1 = env.Install("$BIN", source) >>>> i2 = env.Install("$LOCALBIN", source) >>>> print("TEST_VAR=%s"%env['TEST_VAR']) >>>> return [i1[0], i2[0]] # Return a list, like a normal builder >>>> >>>> env.AddMethod(install_in_bin_dirs, "InstallInBinDirs") >>>> >>>> oenv=OverrideEnvironment(env,TEST_VAR='abc') >>>> >>>> oenv.InstallInBinDirs(env.Program('main.c')) # installs hello in both >>>> bin dirs >>>> >>>> print("Override id:%s"%id(oenv)) >>>> >>>> >>>> >>>> And output: >>>> $ python ~/devel/scons/git/as_scons/src/script/scons.py --debug=explain >>>> scons: Reading SConscript files ... >>>> TypeError: __init__() got an unexpected keyword argument 'TEST_VAR': >>>> File >>>> "/Users/bdbaddog/devel/scons/bugs/Scons-psuedobuilder_no_override_access/SConstruct", >>>> line 15: >>>> oenv=OverrideEnvironment(env,TEST_VAR='abc') >>>> >>>> >>>> >>>> On Thu, Apr 25, 2019 at 6:39 PM Gary Oberbrunner <[email protected]> >>>> wrote: >>>> >>>>> Sorry, I have a cold. >>>>> Still: oenv.InstallInBinDirs(...) ? >>>>> >>>>> --Gary >>>>> >>>>> On Thu, Apr 25, 2019, 6:37 PM Gary Oberbrunner <[email protected]> >>>>> wrote: >>>>> >>>>>> Shouldn't that say oenv.install_in_bin_dir(...)? >>>>>> >>>>>> --Gary >>>>>> >>>>>> On Thu, Apr 25, 2019, 6:06 PM Bill Deegan <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Currently they don't >>>>>>> >>>>>>> See sample git repo: >>>>>>> >>>>>>> https://github.com/bdbaddog/Scons-psuedobuilder_no_override_access/tree/master >>>>>>> >>>>>>> SConstruct: >>>>>>> >>>>>>> DefaultEnvironment(tools=[]) >>>>>>> env=Environment(BIN='mybin',LOCALBIN='localbin') >>>>>>> >>>>>>> def install_in_bin_dirs(env, source): >>>>>>> """Install source in both bin dirs""" >>>>>>> i1 = env.Install("$BIN", source) >>>>>>> i2 = env.Install("$LOCALBIN", source) >>>>>>> print("TEST_VAR=%s"%env['TEST_VAR']) >>>>>>> return [i1[0], i2[0]] # Return a list, like a normal builder >>>>>>> >>>>>>> env.AddMethod(install_in_bin_dirs, "InstallInBinDirs") >>>>>>> >>>>>>> env.InstallInBinDirs(env.Program('main.c')) # installs hello in both bin dirs >>>>>>> >>>>>>> oenv=OverrideEnvironment(env,TEST_VAR='abc') >>>>>>> print("Override id:%s"%id(oenv)) >>>>>>> >>>>>>> >>>>>>> Yields: >>>>>>> $ python ~/devel/scons/git/as_scons/src/script/scons.py >>>>>>> scons: Reading SConscript files ... >>>>>>> KeyError: 'TEST_VAR': >>>>>>> File "/Users/bdbaddog/devel/scons/bugs/Scons-psuedobuilder_no_override_access/SConstruct", line 13: >>>>>>> env.InstallInBinDirs(env.Program('main.c')) # installs hello in both bin dirs >>>>>>> File "/Users/bdbaddog/devel/scons/git/as_scons/src/script/../engine/SCons/Environment.py", line 224: >>>>>>> return self.method(*nargs, **kwargs) >>>>>>> File "/Users/bdbaddog/devel/scons/bugs/Scons-psuedobuilder_no_override_access/SConstruct", line 8: >>>>>>> print("TEST_VAR=%s"%env['TEST_VAR']) >>>>>>> File "/Users/bdbaddog/devel/scons/git/as_scons/src/script/../engine/SCons/Environment.py", line 410: >>>>>>> return self._dict[key] >>>>>>> >>>>>>> This is because PsuedoBuilder's are wrapped with the Environment() they are added to. >>>>>>> >>>>>>> Via MethodWrapper() >>>>>>> >>>>>>> Which caused a couple hours of debugging to find today.. >>>>>>> >>>>>>> Unless someone can propose a reasonable reason it shouldn't I'll file a github issue. >>>>>>> >>>>>>> -Bill >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Scons-users mailing list >>>>>>> [email protected] >>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users >>>>>>> >>>>>> _______________________________________________ >>>>> Scons-users mailing list >>>>> [email protected] >>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users >>>>> >>>> _______________________________________________ >>>> Scons-users mailing list >>>> [email protected] >>>> https://pairlist4.pair.net/mailman/listinfo/scons-users >>>> >>> >>> >>> -- >>> Gary >>> _______________________________________________ >>> Scons-users mailing list >>> [email protected] >>> https://pairlist4.pair.net/mailman/listinfo/scons-users >>> >> _______________________________________________ >> Scons-users mailing list >> [email protected] >> https://pairlist4.pair.net/mailman/listinfo/scons-users >> > > > -- > Gary > _______________________________________________ > Scons-users mailing list > [email protected] > https://pairlist4.pair.net/mailman/listinfo/scons-users > _______________________________________________ Scons-users mailing list [email protected] https://pairlist4.pair.net/mailman/listinfo/scons-users