0
我試圖用答案here來添加一個cython擴展到我的包中。目前,它通過代碼將.py文件從.pyx文件生成一個.c文件,但不創建共享對象.so文件,因此,當我嘗試導入包時,其中一個模塊試圖導入共享對象文件它找不到它。試圖構建一個python包的cython擴展,而不是創建共享對象(.so)文件
我的setup.py文件(這是稍微切下來)是像這樣:
from setuptools import setup
from setuptools.extension import Extension
import os
import numpy
from Cython.Build import cythonize
mypackage_root_dir = os.path.dirname(__file__)
with open(os.path.join(mypackage_root_dir, 'requirements.txt')) as requirements_file:
requirements = requirements_file.read().splitlines()
extensions = [Extension(
name="package.submodule.foo",
sources=["package/submodule/foo.pyx"],
include_dirs=[numpy.get_include()],
)
]
setup(name='package',
version=0.1,
description='...',
author='my name',
author_email='my email',
url="...",
include_package_data=True,
packages=['package',
'package.submodule1',
'package.submodule2',
'package.submodule', # the one that uses the pyx file
],
ext_modules = cythonize(extensions),
install_requires=requirements,
)
我怎樣才能解決這個問題,這樣我可以得到setup.py文件構建共享對象時文件python setup.py install
運行?
你如何稱這個'setup'文件? – hpaulj
with'python setup.py install' – SomeRandomPhysicist
我不是'cython'的專家,但我的腳本需要'python setup.py build_ext --inplace'。這是從turtorials相當標準的腳本。 – hpaulj