My build is structured like:
SConstruct
subdir/SConscript
subdir/module/__init__.py
SConstruct invokes subdir/SConscript as a subsidiary:
# SConstruct
SConscript('subdir/SConscript')
subdir/SConscript imports module:
# subdir/SConscript
from module import foo
do SConsy stuff with foo()...
This works fine until I use variant_dir with subdir/SConscript:
# SConstruct
SConscript('subdir/SConscript', variant_dir='subdir/build', duplicate=0)
The problem is that the import fails because module is no longer in the path, which has been altered by variant_dir.
Is there a standard way to solve this problem in either SCons or Python? I know about the special site_scons directory, but it appears that this directory must exist at the top level with the root SConstruct, and I’d like to keep subdir-specific files under subdir.
Use site_scons dir in project root dir for you module. For example i’ve module xxx, and he is placed :
root/site_scons/xxx/__init__.py. Now, i can import xxx in all of my SConscript files.