Cython& TOX -MODULENOTFOUNDERROR在3.9上,但不是3.8
我正在将我的包装中的一些脚本转换为Cython,以尝试加快执行时间的速度,并且我很难将其与TOX一起使用。
测试是在3.8上通过的,但是在3.9上,我得到了错误:
E ModuleNotFoundError: No module named 'package.subpackage.module'
研究build
文件夹后,3.9构建同时具有module_cpython-38-darwin.so
和module_cpython-39-darwin.so
(而3.8构建仅具有3.8 .so文件)。手动删除3.8 .So文件不会更改任何内容,但它包含在一个而不是另一个文件中仍然很奇怪。
这是我的项目结构:
Project
|
|-pyproject.toml
|-setup.py
|-setup.cfg
|-MANIFEST.in
|-tox.ini
|
|-src
| |
| |-package
| |
| |-subpackage
| |-module.c
| |-module_cpython-38-darwin.so
| |-module.pyx
|
|-tests
| |-test_package.py
到目前为止,我所做的为Cython所做的工作是将以下内容添加到pyproject.toml
,setup.cfg
,setup.py
/code>和subtest.in
# pyproject.toml
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "cython"]
# setup.cfg
[options]
setup_requires =
setuptools_scm
cython
# setup.py
from setuptools import setup, Extension
from Cython.Build import cythonize
ext = Extension('package.subpackage.module', sources=['./src/package/subpackage/module.pyx'])
if __name__ == "__main__":
setup(use_scm_version=True, ext_modules=cythonize([ext]))
# MANIFEST.in
global-include *.so
我不确定.so
文件是否应包含在清单中 - 但是将其从清单中删除并不会更改任何内容。
知道为什么它不起作用吗?我的项目配置做错了什么?
谢谢。
I'm converting some of my scripts in my package to cython to try and speed up execution time, and I'm having some trouble getting it to work with tox.
The tests are passing on 3.8, but on 3.9 I get the error:
E ModuleNotFoundError: No module named 'package.subpackage.module'
Upon investigating the build
folder, the 3.9 build has both module_cpython-38-darwin.so
and module_cpython-39-darwin.so
(whereas the 3.8 build only has the 3.8 .so file). Manually deleting the 3.8 .so file doesn't change anything, but it's still strange that its included in one and not the other.
This is my project structure:
Project
|
|-pyproject.toml
|-setup.py
|-setup.cfg
|-MANIFEST.in
|-tox.ini
|
|-src
| |
| |-package
| |
| |-subpackage
| |-module.c
| |-module_cpython-38-darwin.so
| |-module.pyx
|
|-tests
| |-test_package.py
What I've done so far to accomodate cython is add the following to pyproject.toml
, setup.cfg
, setup.py
, and MANIFEST.IN
# pyproject.toml
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "cython"]
# setup.cfg
[options]
setup_requires =
setuptools_scm
cython
# setup.py
from setuptools import setup, Extension
from Cython.Build import cythonize
ext = Extension('package.subpackage.module', sources=['./src/package/subpackage/module.pyx'])
if __name__ == "__main__":
setup(use_scm_version=True, ext_modules=cythonize([ext]))
# MANIFEST.in
global-include *.so
I'm not sure if .so
files should be included in the manifest - but removing them from the manifest doesn't change anything.
Any idea why it's not working? Have I done something wrong with my project config?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论