Cythonize 将 .so 文件安装到错误的位置



我想问一个关于如何使用Cython,setuptools扩展等配置setup.py的问题。我正在尝试用Cython.Distutilsbuild_ext对子模块进行细胞化。但问题不在于Cython.Distutils的扩展模块(如果存在),因为它没有加载。只有build_ext.因此,我在列表中创建了一个setuptools.extension扩展,然后将扩展对象列表进行cython化。列表中只有一个扩展,如下所示。

Extension("distance", ["kmerdb/distance.pyx"], include_dirs=[np.get_include()])

我尝试了不同的安装方法,从python setup.py installpip install -e .生成轮子文件和安装轮子。我找不到任何有效的方法...

好的,所以我对这个过程知之甚少,这可能就是我挂断的原因,但我已经搜索了整个网站,没有运气。所以在这里。

我正在运行以下 shell 脚本在本地安装我的软件包,它工作正常。问题是安装不会将.so.py文件移动到我尝试导出的kmerdb模块中。有什么建议吗?谢谢

>python setup.py sdist bdist_wheel
>/bin/auditwheel repair --plat manylinux2014_x86_64 dist/kmerdb-*linux_x86_64.whl
>mv wheelhouse/* dist
>rm dist/*linux_x86_64.whl
>pip install dist/kmerdb-*-manylinux2014_x86_64.whl
>ls ~/.pyenv/versions/kdb/lib/python3.10/site-packages/kmerdb-0.6.5-py3.10-linux-x86_64.egg/
distance.cpython-310-x86_64-linux-gnu.so    distance.py    kmerdb    ...

同样,distance.cpython-310-x86_64-linux-gno.so的文件不会移动到kmerdb模块中,即我的 Python 包,我正在尝试在本地安装并配置为.whl上传到 PyPI。

Python 3.10.1 (main, Jan  1 2022, 21:28:19) [GCC 11.1.0] on linux
Cython==0.29.26

setup.py


Extension("distance", ["kmerdb/distance.pyx"], include_dirs=[np.get_include()], define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],),
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=long_description,
long_description_content_type='text/markdown',
author=AUTHOR,
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
download_url=CURRENT_RELEASE,
keywords = ["k-mer", "kmer", "k-merdb", "kmerdb", "kdb"],
classifiers=[
"Development Status :: 1 - Planning",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Software Development :: Libraries :: Python Modules",
],
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
package_dir={'kmerdb': 'kmerdb'},
package_data={'kmerdb': ['CITATION']},
# If your package is a single module, use this instead of 'packages':
#py_modules=['kmerdb'],
#scripts=['bin/kmerdb', 'bin/kmerdb_report.R'],
entry_points={
'console_scripts': ['kmerdb=kmerdb:cli'],
},
install_requires=REQUIRED,#['Cython==0.29.21', 'numpy==1.18.1'],
extras_require=EXTRAS,
include_package_data=True,
license='GPLv3+',
test_suite='test',
#    tests_require=['mamba', 'expect'],
ext_modules=cythonize(extensions),
library_dirs=["."],
zip_safe=False,
)

我将在这里自我回答。该问题源于未正确指定的扩展。

Extension("kmerdb.distance", ["kmerdb/distance.pyx"], include_dirs=[np.get_include()])

我所要做的就是包含完全指定的子模块层次结构的模块名称。修好了!

相关内容

  • 没有找到相关文章

最新更新