py用于同时依赖cython和f2py的软件包

py用于同时依赖cython和f2py的软件包

本文介绍了setup.py用于同时依赖cython和f2py的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想为一个python软件包创建一个setup.py脚本,其中包含几个依赖cython和f2py的子模块.我尝试使用setuptools和numpy.distutils,但到目前为止失败了:

I would like to create a setup.py script for a python package with several submodules that depend on both cython and f2py. I have attempted to use setuptools and numpy.distutils, but have so far failed:

我可以使用setuptools编译cython扩展(并为软件包的其余部分创建安装).但是,我一直无法弄清楚如何使用setuptools生成f2py扩展.经过广泛的搜索,我只发现了相当古老的类似这样的消息,其中指出: f2py模块必须使用numpy.distutils进行编译.

I am able to compile my cython extensions (and create an installation for the rest of the package) using setuptools. I have, however, been unable to figure out how to use setuptools to generate the f2py extension. After extensive searching, I only found rather old messages like this one that state that f2py modules must be compiled using numpy.distutils.

我能够使用numpy.distutils编译我的f2py扩展(并为软件包的其余部分创建安装).但是,我一直无法弄清楚如何获取numpy.distutils来编译我的cython扩展名,因为它总是试图使用pyrex对其进行编译(并且我正在使用特定于cython的扩展名).我进行了一次搜索,以了解如何获取cython文件的numpy.distutils,并且-至少从一年前开始-他们建议应用.似乎应用了这种猴子补丁也限制了可以传递给Cython的选项.

I am able to compile my f2py extensions (and create an installation for the rest of the package) using numpy.distutils. I have, however, been unable to figure out how to get numpy.distutils to compile my cython extensions as it always attempts to use pyrex to compile it (and I am using extensions specific to cython) recent. I have done a search to figure out how to get numpy.distutils for cython files and - at least as of a year ago - they recommend applying a monkey patch to numpy.distutils. It seems applying such a monkey patch also restricts the options that can be passed to Cython.

我的问题是:为依赖于f2py和cython的程序包编写setup.py脚本的推荐方法是什么?将补丁应用到numpy.distutils真的可以继续吗?

My question is: what is the recommended way to write a setup.py script for packages that depend on both f2py and cython? Is applying a patch to numpy.distutils really the way to go still?

推荐答案

您可以像在
中那样分别在setup.py中分别调用它们 http://answerpot.com/showthread.php?601643-cython%20and%20f2py

You can just call each separately in your setup.py as in
http://answerpot.com/showthread.php?601643-cython%20and%20f2py

# Cython extension
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
  ext_modules = [Extension( 'cext', ['cext.pyx'] )],
  cmdclass = {'build_ext': build_ext},
  script_args = ['build_ext', '--inplace'],
)

# Fortran extension
from numpy.distutils.core import setup, Extension
setup(
  ext_modules = [Extension( 'fext', ['fext.f90'] )],
)

您的调用上下文(我认为他们不确定此命名空间)
必须更改当前对象的扩展名和功能
setup()是.

Your calling context (I think they call this namespace, not sure)
has to change as to what the current object Extension and function
setup() is.

第一个setup()调用是distutils.extension.Extension
和distutils.core.setup()

The first setup() call, it's the distutils.extension.Extension
and distutils.core.setup()

第二个setup()调用,它是numpy.distutils.core.Extension
和numpy.distutils.core.setup()

The second setup() call, it's the numpy.distutils.core.Extension
and numpy.distutils.core.setup()

这篇关于setup.py用于同时依赖cython和f2py的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:29