I'm working on a python project and the package supports python 3.6 - 3.10.
There were these 2 lines in the install_requires
list in setup.py
:
"numpy>=1.18.5, <=1.19.5; python_version=='3.6'",
"numpy>=1.19.5; python_version>='3.7'",
And I tried to change them to
"numpy>=1.18.5, <=1.19.5; python_version=='3.6'",
"numpy>=1.23.1; python_version>='3.10'",
"numpy>=1.19.5; python_version>='3.7', <'3.10'",
And when I ran python setup.py install
, I got this error:
$ python setup.py install
# yeah, I know `pip install .` is a better command.
error in mypackage setup command: 'install_requires' must be a
string or list of strings containing valid project/version requirement specifiers; Parse error at "", <'3.10"": Expected string_end
I tried some different variants to specify a python_version
range of 3.7 to 3.9, but none of them worked.
So how do I specify python version range for a specific dependency in setup.py
?
Referring to Complete Grammar, you can use and
to achieve your purpose.
"numpy>=1.18.5, <=1.19.5; python_version=='3.6'",
"numpy>=1.23.1; python_version>='3.10'",
"numpy>=1.19.5; python_version>='3.7' and python_version<'3.10'",