简体   繁体   中英

scons “Import of non-existent variable” env: how to fix?

I'm hoping that all SConscript could share the environment definition from SConstruct, like this:

cat ./SConstruct

import os,sys
env = Environment(ENV = {'PATH' : os.environ['PATH']})
env.SConscript(dirs=['mydir'])

Then under ./mydir

cat ./SConscript

Import('env')
env = env.Clone()

I try to run it:

scons
scons: Reading SConscript files ...

scons: *** Import of non-existent variable ''env''
File "/home/john/mydir/SConscript", line 1, in <module>

So why scons failed to "Import env", is my syntax wrong? Thanks.

As @dirkbaechle said. Change your SConstruct to:

import os,sys
env = Environment(ENV = {'PATH' : os.environ['PATH']})
env.SConscript(dirs=['mydir'], exports='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