[Numpy-discussion] Is this a bug in numpy.distutils ?

David Cournapeau david at ar.media.kyoto-u.ac.jp
Mon Aug 3 23:11:29 EDT 2009


Matthew Brett wrote:
> Hi,
>
> We are using numpy.distutils, and have run into this odd behavior in windows:
>
> I have XP, Mingw, latest numpy SVN, python.org python 2.6.  All the
> commands below I am running from within the 'numpy' root directory
> (where 'numpy' is a subdirectory).
>
> If I run
>
> python setup.py build
>
> I get the following expected error:
>
> '''
> No module named msccompiler in numpy.distutils; trying from distutils
> error: Unable to find vccarsall.bat
> '''
>
> because, I don't have MSVC.
>
> If I run:
>
> python setup.py build -c mingw32
>
> - that works.  But. running
>
> python setup.py build_ext -c mingw32
>
> generates the same error as above.  Similarly:
>
> python setup.py build_ext -c completely_unknown
>
> Ignores the attempt to set the 'completely_unknown'  compiler, whereas
>
> python setup.py build -c completely_unknown
>
> raises a sensible error.  I conclude that the numpy.distutils
> build_ext command is ignoring at least the compiler options.
>
> Is that correct?
>

Short answer:

I am afraid it cannot work as you want. Basically, when you pass an
option to build_ext, it does not affect other distutils commands, which
are run before build_ext, and need the compiler (config in this case I
think). So you need to pass the -c option to every command affected by
the compiler (build_ext, build_clib and config IIRC).

Long answer:

The reason is linked to the single most annoying "feature" of
distutils:  distutils  fundamentally works by running some commands, one
after the other. Commands have subcommands. For Numpy, as far as
compiled code is concerned, it goes like this:  config - build -
build_clib - build_ext (the build command calls all the subcommands
build_* and config).

Now, each command options set is independent on the other (build_ext vs.
config in this case), but if you pass an option to a command it affects
all its subcommands I believe.

cheers,

David



More information about the NumPy-Discussion mailing list