阅读 setup.py 中的"--plat-name"参数



安装程序工具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,
},
…
)

最新更新