将 .py 文件转换为 .pyd 文件

Nab*_*yub 1 dll cpython pyd python-3.x

经过大量搜索无法找到合适的解决方案后,我有我的 python 文件“Main.py”。我想要它的 .pyd 文件,即 Main.pyd。我尝试过使用 Cpython 的方法,即首先我已将“Main.py”文件转换为“Main.c”,但随后无法将“Main.c”转换为“Main.pyd”,而且方法非常困难。我可以吗有一个简单的方法将“Main.py”转换为“Main.pyd”吗?

M. *_* R. 6

我认为你只需要从你的脚本创建一个库。setup.py除了您的之外创建一个新的sample_code.py

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
    Extension("sample_code",  ["sample_code.py"]),
]

setup(
    name = 'My Program',
    cmdclass = {'build_ext': build_ext},
    ext_modules = ext_modules
)
Run Code Online (Sandbox Code Playgroud)

然后用于python setup.py build_ext --inplace生成您的库。您可以在这里找到更多信息。