安装程序工具bdist_wheel
/bdist_egg
命令有一个--plat-name
参数,允许覆盖主机平台名称。 此值被附加到结果文件的名称上,例如mypackage-1.2.3-py2.py3-none-manylinux1_x86_64.whl
.
如何在setup.py
中读取此值? 请注意,我不是在询问运行脚本的主机平台,例如platform.system()
。 我想要安装工具正在使用的平台名称。
在bdist_egg
(而且只有它;bdist_wheel
只是运行bdist_egg
(--plat-name
参数存储在self.plat_name
中。因此,您可以使用自定义类覆盖bdist_egg
并使用self.plat_name
:
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
from setuptools import setup
class bdist_egg(_bdist_egg):
def run(self):
# Use self.plat_name before building an egg…
_bdist_egg.run(self)
# …or after
setup(
…
cmdclass={
'bdist_egg': bdist_egg,
},
…
)