I have a package that is supposed to be Python version 2 only but needs to be build running a version 3 interpreter.
The setup.py
of this package looks something like hits:
from setuptools import setup
setup(
python_requires="<3.0, >=2.7.5",
classifiers=[
'Programming Language :: Python :: 2',
'Intended Audience :: Developers',
],
# ... more keyword arguments ...
)
If I call python2 setup.py build bdist_wheel
, I get:
$ ls dist
mypackage-0.3.dev14-py2-none-any.whl
If I run it with a version 3 interpreter, i.e. python3 setup.py build bdist_wheel
, I get:
$ ls dist
mypackage-0.3.dev14-py3-none-any.whl
I would have expected that regardless of the interpreter version, I will get a py2 package, because I specified it with python_requires
(and in the tags). My package build server only has a Python 3 interpreter.
How can I build a wheel that targets Python 2 when running setuptools with a Python 3 interpreter? Is that at all possible? Does the -py3-
/-py2
in the filename mean something different than I think it does?
Try passing the python-tag argument to bdist_wheel:
python setup.py bdist_wheel --python-tag=py2
It could also be passed as
from setuptools import setup
setup(options={'bdist_wheel':{'python_tag':'py2'}})
Or in setup.cfg