我正在尝试为我的领域中的一些流行的Fortran代码进行python包分发.我希望它对setup.py文件使用最标准的方法.相关的qustion有助于学习如何包装Fortran扩展.
当使用这种方法,我混合时发现一些容易混淆的行为setuptools和numpy.distutils.将两者混合是不好的做法吗?截至2015年,似乎最好setuptools尽可能多地使用.
但是,我想以Fortran一种兼容的方式构建扩展numpy. 所以我想从中导入numpy.distutils以获取Extension和setup.
我使用以下基本方法:
from setuptools.command.develop import develop
from numpy.distutils.core import Extension, setup
ext_modules=[Extension("my_package.fortran_mod", sources=['src/fortran_mod.f'])]
class MyDevelop(develop):
def run(self):
my_script()
develop.run(self)
setup(
...
ext_modules=ext_modules,
cmdclass={'develop':MyDevelop})
Run Code Online (Sandbox Code Playgroud)
这似乎有效,但我有疑问.
setuptools和一般是好的做法numpy.distribute吗?setuptools先进口吗?numpy?也许甚至有一些讨论Fortran扩展?https://www.youtube.com/watch?v=R4yB-8tB0J0
http://www.fortran90.org/src/best-practices.html#interfacing-with-python