我使用 Poetry 来构建 tar.gz。和我的包裹的.whl。Cython 文档建议将 cython 生成的 c 文件与 pyx 文件一起分发。http://docs.cython.org/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
我应该通过调用和添加什么build.py
或pyproject.toml
生成 c/cpp 文件?poetry build
poetry build -f sdist
我试过这个(来自Create package with cython so users can install it without cython already installed):
构建.py:
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist as _sdist
...
class sdist(_sdist):
def run(self):
# Make sure the compiled Cython files in the distribution are up-to-date
self.run_command("build_ext")
_sdist.run(self)
def build(setup_kwargs):
setup_kwargs.update({
...
'cmdclass': {'sdist': sdist,
'build_ext': build_ext}
})
不适合我。