[Scons-users] Invoking SCons as a function?

Daniel Holth dholth at gmail.com
Fri Jun 30 21:04:01 EDT 2017


Wrote some code to invoke SCons from a function and return a certain
target name [which may or may not have been built]. Needed for
https://www.python.org/dev/peps/pep-0517/ which defines a Python API
for installers to call against build backends.


One important drawback to this technique is that you can't call it a
second time in the same process to redefine wheel_directory or build a
second target, even if you were wrapping SCons interactive mode
instead of calling main() as in the example. For pip and PEP 517 it
might ask for an sdist and a wheel, but the API expects to build one
before telling us the target directory for the other.


Is there a way for SCons e.g. in interactive mode to accept arguments
changing the target directory for builds? Maybe something with variant
directories?


Thanks,


Daniel


def build_wheel(wheel_directory, settings, metadata_directory=None):
 sys.argv[1:] = ['--wheel-dir=' + wheel_directory, 'bdist_wheel']
print sys.argv    try:        SCons.Script.Main.main()    except
SystemExit as e:        pass    for target in
SCons.Script.DEFAULT_TARGETS:        target_name = str(target)
if target_name.endswith('.whl'):            return
os.path.basename(target_name)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170701/725190d8/attachment-0001.html>


More information about the Scons-users mailing list