我有一个包应该是 Python version 2 only 但需要构建运行 version 3 解释器。
这个包的 setup.py
看起来像 hits:
from setuptools import setup
setup(
python_requires="<3.0, >=2.7.5",
classifiers=[
'Programming Language :: Python :: 2',
'Intended Audience :: Developers',
],
# ... more keyword arguments ...
)
如果我调用
python2 setup.py build bdist_wheel
,我会得到:$ ls dist
mypackage-0.3.dev14-py2-none-any.whl
如果我用版本 3 解释器运行它,即
python3 setup.py build bdist_wheel
,我得到:$ ls dist
mypackage-0.3.dev14-py3-none-any.whl
我本来希望无论解释器版本如何,我都会得到一个 py2 包,因为我用
python_requires
(和在标签中)指定了它。我的包构建服务器只有一个 Python 3 解释器。在使用 Python 3 解释器运行 setuptools 时,如何构建面向 Python 2 的轮子?这可能吗?文件名中的
-py3-
/-py2
是否与我认为的不同? 最佳答案
尝试将 python-tag 参数传递给 bdist_wheel:python setup.py bdist_wheel --python-tag=py2
它也可以作为
from setuptools import setup
setup(options={'bdist_wheel':{'python_tag':'py2'}})
或者在
setup.cfg
中关于python - 当 setup.py 使用 Python 版本 3 解释器运行时,如何构建 py2 wheel 包?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54988279/