简体   繁体   中英

Get current environment

I know I can create a new environment in my SConstruct and, in some way, it works and the environment is passed on along the execution thread.

This is my Sconstruct:

env = Environment() 
env.SConscript('site_scons/environment.py', 'env')
Export('env')  

This is environment.py

from SCons.Script import Import # Seems like it's not really needed
Import('env')
env = env.Clone() # NameError: name 'env' is not defined:

Interestingly enough, if I put a breackpoint after the Clone call, I can use the env object and the exception is raised later .

      5 env = env.Clone()
----> 6 import ipdb; ipdb.set_trace()

ipdb> env
<SCons.Script.SConscript.SConsEnvironment object at 0x2b3dad0>
ipdb> c
NameError: name 'env' is not defined:

Is there a proper way to acquire the current running Environment?

Please note that I need to use the environment object in a python module not just a SConscript.

I think you need to explicitly export the env to be able to import it. See here So, like

env = Environment(tools=['default', 'qt4'])
Export('env')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM