I need to import python3 scripts within a scons script. (I use scons v3.0.1.7)
Is there a way to execute scons with python 3 ?
The offical scons site says
This will be the first release to support Python versions earlier than 2.7 as well as 3.5+
Something like scons -python /usr/bin/python3
would be good to select the python interpreter.
I did not find either how to build a scons version for python3.
SCons will work with Python 2.7. x or with Python 3.5 or later. If you need to install Python and have a choice, we recommend using the most recent Python version available. Newer Pythons have significant improvements that help speed up the performance of SCons.
The recommended way to install for most situations is the Python wheel package, available from the Python Package Index (see https://pypi.org/project/SCons/) which you install using the pip command. This may be available through alternate installers such as Anaconda as well, through the efforts of volunteers.
Here is a better solution, add this to your .bash_profile:
alias scons3="/usr/bin/env python3 $(which scons)"
In the latest versions, SCons supports both Python2 and Python3. There is no need to recompile SCons itself or such. All that matters is which Python version is the default on your system.
You don't mention under which OS you're trying to get this working, so I assume a Linux for now. After the installation you can find the scons
script in a location like /usr/local/bin/scons
(try "which scons
" if in doubt). The first line
#! /usr/bin/env python
tells your system to use the default Python version. If this is not what you want, you can simply change it to e.g.
#! /usr/bin/env python3
if you're under a Python2-default system, but want to run SCons with Python3 instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With