Closed georgealton closed 5 years ago
Does that actually work? It's an honest question: I never specify versions in setup.py, only in requirements.txt.
If I'm installing a 3.7 venv with a requirements.txt that specifies dataclasses
, with no python_requires
, will pip not install dataclasses
if its setup.py says python_requires = '<3.7'
?
That's my interpretation of the option from the guide; https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
I just had a go at creating that scenario - pip refused to install my local modified version of dataclasses with the marker;
Here usage of this functionality in hypothesis https://github.com/HypothesisWorks/hypothesis/blob/f6642662f9f56687817e49c6fd25c30e79d2b2a6/setup.py#L77
It indeed works, by adding data value in the pip index which pip honors. You can see this data by looking at the source of index for some package. Even for pip
itself, check source code of https://pypi.org/simple/pip
An example lines looks like this:
<a href="https://files.pythonhosted.org/....."
data-requires-python=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*">
pip-19.2.tar.gz
</a>
<br/>
I just released 0.7 on pypi to address this issue. Sorry for the long delay.
With typing
already being present in python 3.5, why is this backport 3.6 only?
Because variable annotations (PEP 526) didn't show up until 3.6, and dataclasses requires them.
Oh I thought it would only be the format strings
f"Some {variable!r}"
which could be "downgraded" to
"Some {variable!r}".format(variable=variable)
Thanks for clarifying.
Would adding a
python_requires = '<3.7',
configuration to the setup.py, to prevent this package from being installed in python environments >=3.7, be helpful?This would help to prevent accidental shadowing of the builtin dataclass package, and then triggering some of the incompatability issues