Quantcast

f2py and setup.py how can I specify where the .so file goes?

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

f2py and setup.py how can I specify where the .so file goes?

Jose Gomez-Dans
Hi, 
I am building a package that exposes some Fortran libraries through f2py. The packages directory looks like this:
setup.py
my_pack/
  |
  |---------->__init__.py
  |----------> some.pyf
  |-----------> code.f90

I thoughat that once installed, I'd get the .so and __init__.py in the same directory (namely ~/.local/lib/python2.7/site-packages/my_pack/). However, I get
~/.local/lib/python2.7/site-packages/mypack_fortran.so
~/.local/lib/python2.7/site-packages/my_pack__fortran-1.0.2-py2.7.egg-info
~/.local/lib/python2.7/site-packages/my_pack/__init__.py

Thet setup file is this at the end, I am clearly missing some option here to move the *.so into the my_pack directory.... Anybody know which one?

Cheers
Jose

[setup.py]

#!/usr/bin/env python


def configuration(parent_package='',top_path=None):
    from numpy.distutils.misc_util import Configuration
    config = Configuration(parent_package,top_path)
    config.add_extension('mypack_fortran', ['the_pack/code.f90'] )
    return config

if __name__ == "__main__":
    from numpy.distutils.core import setup
    # Global variables for this extension:
    name         = "mypack_fortran"  # name of the generated python extension (.so)
    description  = "blah"
    author       = ""
    author_email = ""
    
    setup( name=name,\
        description=description, \
        author=author, \
        author_email = author_email, \
        configuration = configuration, version="1.0.2",\
        packages=["my_pack"])


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: f2py and setup.py how can I specify where the .so file goes?

Scott Sinclair-4
On 10 July 2013 17:50, Jose Gomez-Dans <[hidden email]> wrote:

> Hi,
> I am building a package that exposes some Fortran libraries through f2py.
> The packages directory looks like this:
> setup.py
> my_pack/
>   |
>   |---------->__init__.py
>   |----------> some.pyf
>   |-----------> code.f90
>
> I thoughat that once installed, I'd get the .so and __init__.py in the same
> directory (namely ~/.local/lib/python2.7/site-packages/my_pack/). However, I
> get
> ~/.local/lib/python2.7/site-packages/mypack_fortran.so
> ~/.local/lib/python2.7/site-packages/my_pack__fortran-1.0.2-py2.7.egg-info
> ~/.local/lib/python2.7/site-packages/my_pack/__init__.py
>
> Thet setup file is this at the end, I am clearly missing some option here to
> move the *.so into the my_pack directory.... Anybody know which one?
>
> Cheers
> Jose
>
> [setup.py]
>
> #!/usr/bin/env python
>
>
> def configuration(parent_package='',top_path=None):
>     from numpy.distutils.misc_util import Configuration
>     config = Configuration(parent_package,top_path)
>     config.add_extension('mypack_fortran', ['the_pack/code.f90'] )
>     return config
>
> if __name__ == "__main__":
>     from numpy.distutils.core import setup
>     # Global variables for this extension:
>     name         = "mypack_fortran"  # name of the generated python
> extension (.so)
>     description  = "blah"
>     author       = ""
>     author_email = ""
>
>     setup( name=name,\
>         description=description, \
>         author=author, \
>         author_email = author_email, \
>         configuration = configuration, version="1.0.2",\
>         packages=["my_pack"])

Something like the following should work...

from numpy.distutils.core import setup, Extension

my_ext = Extension(name = 'my_pack._fortran',
                              sources = ['my_pack/code.f90'])

if __name__ == "__main__":
    setup(name = 'my_pack',
             description = ...,
             author =...,
             author_email = ...,
             version = ...,
             packages = ['my_pack'],
             ext_modules = [my_ext],
          )

Cheers,
Scott
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: f2py and setup.py how can I specify where the .so file goes?

Jose Gomez-Dans
Hi Scott, thanks for your help.
On 12 July 2013 10:02, Scott Sinclair <[hidden email]> wrote:
Something like the following should work... [...]
 
Your suggestion works like what I already had. The issue is that the .so created by the Extension is copied to copying 
<blah/blah>/lib/python2.7/site-packages/
and not to 
<blah/blah>/lib/python2.7/site-packages/my_pack

As it is, Python finds it with no problems (as site-packages is in the PYTHONPATH), but I'm worried that that might not be the case with all possible setups. But maybe that's the way it's suppossed to work.

Thanks!
Jose

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: f2py and setup.py how can I specify where the .so file goes?

jgoppert
This post has NOT been accepted by the mailing list yet.
You can control it with the Configuration arguments: parent_package and top_path. This will put it in the proper place.
Loading...