[Numpy-discussion] numpy.distutils: building a f2py in a subdir

Pearu Peterson pearu@cens.ioc...
Sun May 18 05:49:00 CDT 2008

On Sun, May 18, 2008 1:14 pm, David Cournapeau wrote:
> Hi,
>     I would like to be able to build a f2py extension in a subdir with
> distutils, that is:
> config.add_extension('foo/bar', source = ['foo/bar.pyf'])

A safe approach would be to create a foo/setup.py that contains
  config.add_extension('bar', source = ['bar.pyf'])
and in the parent setup.py add
(you might also need creating foo/__init__.py).

> But it does not work right now because of the way numpy.distutils finds
> the name of the extension. Replacing:
> ext_name = extension.name.split('.')[-1]
> by
> ext_name = os.path.basename(extension.name.split('.')[-1])
> Seems to make it work. Could that break anything in numpy.distutils ? I
> don't see how, but I don't want to touch distutils without being sure it
> won't,

The change should not break anything that already works because
in distutils extension name is assumed to contain names joined with a dot.
If distutils works with / in extension name, then I think it is because
by an accident. I'd recommend checking this also on a windows system
before changing numpy.distutils, not sure if it works or not there..


More information about the Numpy-discussion mailing list