cython linux so,更改Cython的.so文件命名规则
此行為已在distutils包中定義。distutils使用sysconfig和“EXT_SUFFIX”配置變量:# Lib\distutils\command\build_ext.py
def get_ext_filename(self, ext_name):
r"""Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
"""
from distutils.sysconfig import get_config_var
ext_path = ext_name.split('.')
ext_suffix = get_config_var('EXT_SUFFIX')
return os.path.join(*ext_path) + ext_suffix
從python3.5開始,“EXT_SUFFIX”變量包含平臺信息,例如“.cp35-win_amd64”。在
我編寫了以下函數:
^{pr2}$
和自定義build\u ext命令:from Cython.Distutils import build_ext
class BuildExtWithoutPlatformSuffix(build_ext):
def get_ext_filename(self, ext_name):
filename = super().get_ext_filename(ext_name)
return get_ext_filename_without_platform_suffix(filename)
用法:setup(
...
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
...
)
總結
以上是生活随笔為你收集整理的cython linux so,更改Cython的.so文件命名规则的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux的crontab监控,通过cr
- 下一篇: linux ps mp,Linux中的命