Re: [f2py] example of setup.py

Pearu Peterson <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
On Tue, May 5, 2009 at 7:25 PM, Thomas Robitaille
<[email protected]> wrote:
> Hi,
>
> Does anyone have an example of a simple setup.py file to build a module
> which includes both python and fortran sources?
>
> It seems that numpy.distutils should be used, not scipy_distutils (which
> doesn't seem to exist anymore), but I can't manage to find a simple example.
> Say I have three files:
>
> mymodule/__init__.py
> mymodule/somecode.py
> src/fastcalc.f90
>
> What is the simplest setup.py file I can use to build this module?

Here is an example of a setup.py file (not tested):

#!/usr/bin/env python
def configuration(parent_package='',top_path=None):
    from numpy.distutils.misc_util import Configuration
    config = Configuration('mymodule',parent_package,top_path)
    config.add_extension('fastcalc', ['src/fastcalc.f90'])
    return config

if __name__ == "__main__":
    from numpy.distutils.core import setup
    setup(configuration=configuration)

More examples are in

  numpy/distutils/tests/

directory.

HTH,
Pearu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.