2

I have requirements.txt file, where I give the custom-package name with version as below,

custom-package >= 1.0.1

Now in my repo, i have versions like below

custom-package-1.0.1.tar.gz
custom-package-1.0.4.tar.gz
custom-package-5.0.0.tar.gz

now if I run pip install requirements.txt , then it picks up 5.0.0. which is understandable. But how can I make sure, it should only pick up the version starts with 1 not with 5.

1
  • custom-package == 1.0.1?
    – MarshalSHI
    Commented Jun 12, 2020 at 9:53

3 Answers 3

7

If you want any version that starts with 1, just specify that the version shouldn't exceed 2.0.0:

custom-package >= 1.0.1, < 2.0.0

or if you want an exact version:

custom-package == 1.0.1
1
  • let me try with ~= , and your suggestion with ` > and < ` options
    – change198
    Commented Jun 12, 2020 at 10:57
0

If you want to choose any version starting with '1', just do:

custom-package == 1.*
4
  • But the picked version can be for example 1.0.0 which is lower than 1.0.1 Commented Jun 12, 2020 at 9:58
  • requirement says it should only pick up the version starts with 1 not with 5. I think this might suffice Commented Jun 12, 2020 at 10:01
  • @AminGuermazi - again, the question is pretty specific about it: "it should only pick up the version starts with 1". As "1.*" starts with one, I believe it answers the question.
    – Roy2012
    Commented Jun 12, 2020 at 13:55
  • Exactly, He downvoted my answer too! based on how he understood the question Commented Jun 12, 2020 at 20:07
-1
custom-package==1.*

This should do

4
  • But the picked version can be for example 1.0.0 which is lower than 1.0.1 Commented Jun 12, 2020 at 9:58
  • requirement says it should only pick up the version starts with 1 not with 5. I think this might suffice Commented Jun 12, 2020 at 10:01
  • But not in all cases, specifying the starting version number is always more precise Commented Jun 12, 2020 at 10:03
  • 1.0.0 is okay , please read 'pick up the version starts with 1'. i dont undersatnd how 1.0.0 doesn't start with 1? Commented Jun 12, 2020 at 10:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.