numpy.distutils: building a f2py in a subdir

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

numpy.distutils: building a f2py in a subdir

cdavid
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'])

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,

cheers,

David

_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: numpy.distutils: building a f2py in a subdir

Robert Kern-2
On Sun, May 18, 2008 at 5:14 AM, David Cournapeau
<[hidden email]> 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'])
>
> But it does not work right now because of the way numpy.distutils finds
> the name of the extension.

Is foo a subpackage and the extension is supposed to be imported as
parent.foo.bar (assuming the setup.py is for the "parent" package)? If
so, you want this:

config.add_extension('foo.bar', source=['foo/bar.pyf'])

If the source is just in a subdirectory, but bar.so should be imported
as "parent.bar", then you want this:

config.add_extension('bar', source=['foo/bar.pyf'])

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco
_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: numpy.distutils: building a f2py in a subdir

cdavid
Robert Kern wrote:
>
> config.add_extension('foo.bar', source=['foo/bar.pyf'])
>  

Duh, should have thought about that.

thanks,

David
_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: numpy.distutils: building a f2py in a subdir

Pearu Peterson-3
In reply to this post by cdavid
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
  config.add_subpackage('foo')
(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..

Pearu

_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion