I spent almost an hour googling for the solution, but the documentation for numpy.distutils is very sparse.
I have a f2py-wrapped module. It consists basically of 3 files:
a.f90
a.pyf
lib.a <- this is a static library that contains most of the computational code
The module is well compiled with the following shell-script command.
f2py --build-dir temp -c a.pyf a.f90 lib.a --fcompiler=gnu95
--fcompiler-flags="Zillions of compiler options"
As a result, I have the python module a.so (the name is specified in the .pyf file).
How do I do that with numpy.distutils (or some other python-oriented building tools)? A less important question is, can I also include the dependence from lib.a (and rebuild it when necessary?)
So, it is not 1 hour of Googling, it took 2 days of Googling, but finally I found the way to do that. Hope, it will be helpful to someone.
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration, get_info
config = Configuration('a', parent_package, top_path)
lib = ['./libdir/lib.a']
src = ['a.f90','a.pyf']
inc_dir = ['libdir']
config.add_extension('mya',sources=src,depends=lib_tt,
include_dirs=inc_dir,extra_objects="lib.a")
#The main trick was to use extra_objects keyword
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With