使现代化
另请参阅更详细的答案
here
。
您可以通过查询
bdist_wheel
命令,为此您甚至不需要构建任何东西或编写
setup.py
脚本(但您需要传递给的元数据
setup
功能)。示例:
from distutils.core import Extension
from setuptools.dist import Distribution
fuzzlib = Extension('fuzzlib', ['fuzz.pyx']) # the files don't need to exist
dist = Distribution(attrs={'name': 'so', 'version': '0.1.2', 'ext_modules': [fuzzlib]})
bdist_wheel_cmd = dist.get_command_obj('bdist_wheel')
bdist_wheel_cmd.ensure_finalized()
distname = bdist_wheel_cmd.wheel_dist_name
tag = '-'.join(bdist_wheel_cmd.get_tag())
wheel_name = f'{distname}-{tag}.whl'
print(wheel_name)
将为您打印所需的姓名。请注意
attrs
传递给
Distribution
应包含传递给的相同元数据
设置
函数,否则可能会得到错误的标记。要重用元数据,请在
setup.py
脚本这可以像例如。
setup_kwargs = {'name': 'so', 'version': '0.1.2', ...}
dist = Distribution(attrs=setup_kwargs)
...
setup(**setup_kwargs)