Reputation: 4821
Suppose I am using pip
to install a package foo
in Python 3. Now suppose that foo
version 1.0 works great for Python 3.5 or lower, but breaks for Python 3.6 or higher. And suppose that foo
version 2.0 works great for Python 3.6 or higher.
How can I specify in my requirements.txt
that pip should install foo==2.0
if Python interpreter is 3.6 or higher, and foo==1.0
if Python interpreter is 3.5 or lower?
Upvotes: 6
Views: 2469
Reputation: 451
It realy easy. The solve is PEP 508 -- Dependency specification for Python Software Packages. You must use environment markers. This will allow you to specify different versions of packages for different python versions. For example:
foo==2.0;python_version>="3.6"
foo==1.0;python_version<"3.6"
Upvotes: 13