小编Ano*_*non的帖子

Cython 编译将文本附加到文件名中,如何摆脱它?

我正在 Ubuntu 平台上使用 cython。一切都很好,除了一件事让我烦恼。将 cython 项目编译为 .so 文件时,.pyx 文件的文件名会附加“cpython-36m-x86_64-linux-gnu”。例如,如果我构建“helloworld.pyx”,则生成的 .so 文件称为:“helloworld.cpython-36m-x86_64-linux-gnu.so”。然而,我只想将其命名为“helloworld.so”。

我认为答案是相当微不足道的,所以我开始谷歌搜索,即使在 30 分钟后我也找不到任何关于这个主题的信息。有人有什么主意吗?

这是我的 .pyx 文件:

print('hello world')
Run Code Online (Sandbox Code Playgroud)

setup.py 文件:

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)
Run Code Online (Sandbox Code Playgroud)

构建文件:

python setup.py build_ext --inplace
Compiling helloworld.pyx because it changed.
[1/1] Cythonizing helloworld.pyx
running build_ext
building 'helloworld' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/**/anaconda3/include/python3.6m -c helloworld.c -o build/temp.linux-x86_64-3.6/helloworld.o
gcc -pthread -shared -L/home/**/anaconda3/lib -Wl,-rpath=/home/ed/anaconda3/lib,--no-as-needed build/temp.linux-x86_64-3.6/helloworld.o -L/home/**/anaconda3/lib -lpython3.6m -o /home/**/new_project/helloworld.cpython-36m-x86_64-linux-gnu.so
Run Code Online (Sandbox Code Playgroud)

python gcc distutils cython cythonize

6
推荐指数
1
解决办法
2048
查看次数

标签 统计

cython ×1

cythonize ×1

distutils ×1

gcc ×1

python ×1