python - 在 setup.py 中读取“--plat-name”参数
问题描述
setuptools bdist_wheel
/bdist_egg
命令有一个--plat-name
允许覆盖主机平台名称的参数。该值被附加到结果文件的名称上,例如mypackage-1.2.3-py2.py3-none-manylinux1_x86_64.whl
.
我怎样才能读到这个值setup.py
?注意我不是在询问脚本运行的主机平台,例如platform.system()
. 我想要 setuptools 正在使用的平台名称。
解决方案
在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,
},
…
)
推荐阅读
- python - 使用 matplotlib 移动圆
- python - Webscraper 中的 KeyError(f"[{key}] 中没有 [{axis_name}]")
- javascript - WebRTC Node.JS WebSocket 服务器,如果 WSS 参数不是 1,则阻止请求
- python - 在这种情况下,如何在 python 中重置单例实例?
- xcode - air-lld:错误:将 xcode 更新为 xcode 12 后,未找到目标“air64-apple-ios12.0.0”的符号
- css - 如何修复 CSS,因为它在 Iphone 中不起作用?偏移距离,偏移路径
- javascript - 为什么即使在我的 NodeJS 服务器上进行了空检查,req.headers 上仍会引发“无法读取未定义的属性'替换'”错误?
- firebase - documentSnapshot.data() do not pass to the builder: Flutter
- git - “git reset hard”的事故
- r - 如何组织最终表格以模拟具有不同样本大小的 r 中的最大似然?