[Numpy-discussion] Bitting the bullet: using scons to build extensions inside distutils ?
Sat Sep 22 10:56:16 CDT 2007
On 9/17/07, Matthew Brett <firstname.lastname@example.org> wrote:
> > Starting thinking over the whole distutils thing, I was thinking
> > what people would think about using scons inside distutils to build
> > extension.
> In general this seems like an excellent idea. If we can contribute
> what we need to scons, that would greatly ease the burden of
> maintenance, and benefit both projects. The key problem will be
> support. At the moment Pearu maintains and owns numpy.distutils.
> Will we have the same level of commitment and support for this
> alternative do you think?
> How easy would it be to throw up a prototype for the rest of us to
> look at and get a feel for what the benefits would be?
Here we are for those interested: all the work is in the branch numpy.scons.
Basically, I added a command scons to numpy.distutils, and add a
add_sconscript hook to the config class. An example can be found in
numpy/scons_fake. You are expected to do
python setup.py scons
To build them (I have not found a way yet to tell the install command
to call scons command; but the current implementation put the built
code where distutils expects it, so if you call scons and then
install, it should be ok).
This is only a proof of concept, but as an example, I started to
implement a small support library for sconscript to be used inside
numpy, and got ctypes extension building working on both windows and
The Sconscript file:
from numpy.distutils.scons import GetNumpyEnvironment
env = GetNumpyEnvironment(ARGUMENTS)
source = ['foo.c']
if sys.platform == 'win32':
env.AppendUnique(CPPDEFINES = 'WIN32')
And in the setup.py, you just do:
Once numpy with scons support is installed, partial build is possible
(by partial I mean only using python setup.py scons in a subpackage).
This should give a feel on how it would behave for users. If people
think this is the right direction, then I can add more complete
support (mostly making scons behave as distutils with respect to how
to find extension using setup.cfg, implementing the checks in
numpy/distutils/system_info for scons, passing the compilers/linkers
to scons, etc...).
More information about the Numpy-discussion