How to pip install a package with min and max version range?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Isolated
--
Chapters
00:00 How To Pip Install A Package With Min And Max Version Range?
01:00 Accepted Answer Score 597
01:21 Answer 2 Score 184
01:32 Answer 3 Score 202
02:04 Answer 4 Score 19
02:27 Thank you
--
Full question
https://stackoverflow.com/questions/8795...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pip #multipleversions
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Isolated
--
Chapters
00:00 How To Pip Install A Package With Min And Max Version Range?
01:00 Accepted Answer Score 597
01:21 Answer 2 Score 184
01:32 Answer 3 Score 202
02:04 Answer 4 Score 19
02:27 Thank you
--
Full question
https://stackoverflow.com/questions/8795...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pip #multipleversions
#avk47
ACCEPTED ANSWER
Score 597
You can do:
$ pip install "package>=0.2,<0.3"
And pip will look for the best match, assuming the version is at least 0.2, and less than 0.3.
This also applies to pip requirements files. See the full details on version specifiers in PEP 440.
ANSWER 2
Score 202
An elegant method would be to use the ~= compatible release operator according to PEP 440. In your case this would amount to:
package~=0.5.0
As an example, if the following versions exist, it would choose 0.5.9:
0.5.00.5.90.6.0
For clarification, each two lines in a pair are equivalent:
~= 0.5.0
>= 0.5.0, == 0.5.*
~= 0.5
>= 0.5, == 0.*
ANSWER 3
Score 184
you can also use:
pip install package==0.5.*
which is more consistent and easy to read.
ANSWER 4
Score 19
nok.github.io/pipdev is an interactive tool for developers to test defined specifiers for version handling.
Related to the question: nok.github.io/pipdev?spec=~=0.5.0&vers=0.6
