[Scons-users] Python 3 support

Fred Wright fw at fwright.net
Thu Apr 13 16:18:10 EDT 2017


On Thu, 13 Apr 2017, Russel Winder wrote:
> On Thu, 2017-04-13 at 08:10 -0500, robert zeigler wrote:
> > I have a project that is using scons under the hood. We are in the
> > process
> > of migrating our codebases to python 3. I'm curious: what are the
> > major
> > road blocks right and considerations for scons to support Python 3?
> > I'm
> > supposed to have a vacation in a couple of weeks and was thinking of
> > spending some time working on the problem.
>
> SCons is close to being ready to run on Python 3 – in fact it already
> does for many builds, but it doesn't pass all the tests yet so cannot
> be marketed as Python 2 and Python 3 compatible.

There's no need to run SCons under Python 3 just to build code for Python
3.  More generally, there's no need to run SCons under Python X.Y to build
for Python X.Y.  But the build script does have to support the concept of
"target Python" and "SCons Python" being independent.

The biggest problem I ran into when making this work for GPSD is that it
needs to obtain certain configuration parameters from Python, which can be
done via direct Python calls when targeting the SCons Python, but not
otherwise.  The solution I came up with is to execute Python fragments via
"<some Python> -c <print something>", capture the stdout result, and feed
it through ast.literal_eval to convert it to Python data.

Making this work properly when cross-building would be more challenging,
but that's true even when targeting the same Python version.

Fred Wright


More information about the Scons-users mailing list