[Numpy-discussion] New bug with "setup,py develop"

David Cournapeau cournape@gmail....
Mon Feb 11 20:10:57 CST 2008


On Feb 11, 2008 5:40 PM, Charles R Harris <charlesr.harris@gmail.com> wrote:
>
>
>
> On Feb 11, 2008 1:21 AM, Robert Kern <robert.kern@gmail.com> wrote:
>
> > I've just updated the SVN trunk to get the latest numscons merge.
> > Something broke the support I put in for the setuptools "develop"
> > command. In order to make sure that setuptools' "develop" works with
> > numpy.distutils' "build_src", we override the "develop" command to
> > reinitialize the "build_src" command to add the --inplace option. This
> > used to work as of r4772, but now any Fortran Extensions have the
> > generated sources added twice. This causes links to fail since the
> > same symbol shows up twice.
> >
>
> While we're talking build, how do I set the compiler flags? Numpy here
> always compiles with -march=i386, which seems a bit conservative. My
> environment flags are also ignored, but I assume there is someway of getting
> the compile to behave.
Well, you assumed wrong :) It is one of the reasons why I started
working on scons support. It is extremely ackward to control
compilation flags with the python distutils from stdlib, and by design
(flags are added at several different locations, which depend on the
platform, and understanding the exact logic is beyond mere mortal
capability).

You can use CFLAGS with distutils, but I don't really understand
what's happening in this case: it seems that they are appended to the
current compilation flags, but the order also seems to depend on the
architecture. Sometimes they are inserted toward the end of
compilation flags.

With numscons, CFLAGS override the optimization/warning flags (but not
-fPIC, etc... which are necessary to build the code; internally,
optimization/debug/warning/necessary flags are separated). One
example: with numpy.distutils, compiling for debug is not trivial:

CFLAGS="-DDEBUG" python setup.py build

will still compile with -O2, and with -DNDEBUG. You need to add -O0 to
override the default O2 used by distutils (at least for gcc, when
several options of the same kind are given, the last one wins), and
you have problems for options which cannot be overriden by later
options. With numscons:

CFLAGS="-DDEBUG"

will compile with only this option (and -fPIC, etc... on linux). I
intend to add more options on the UI, but anway, they will be all
overridable (for example, only overriding warning flags, etc...).

cheers,

David


More information about the Numpy-discussion mailing list