Pip: Specifying minor version
Asked Answered
R

2

39

In my requirements.txt file I want to specify that my app needs Django version 1.3.x. That is, either 1.3.0, or 1.3.1, or 1.3.2, etc. (When these come out.) But not 1.4, when it comes out.

What's the syntax for this?

Rest answered 18/5, 2011 at 16:5 Comment(0)
D
53

According to Ian Bicking:

Django>=1.3,<1.4

However, it's apparently safer to do:

Django>=1.3,<1.3.99
Drucie answered 18/5, 2011 at 16:24 Comment(3)
Maybe it's obvious, but beware that if you want to automatically upgrade Django when a new version comes out on PyPI, you should call pip with the --upgrade flag, like this: pip install --upgrade -r requirements.txtNeology
What happens if you (hypothetically) had Django v1.3.100 or later?Usage
You can use ~=1.3.0 to get the latest patch version, see nok.github.io/pipdev?spec=~=1.3.0&vers=1.3.9999 .Yves
S
2

my app needs Django version 1.3.x

In your case, use one of:


Compatible release

Django~=1.3.0

Ref: PEP 440 Compatible release


Version matching

Django==1.3.*

Ref: PEP 440 Version matching


Ordered comparison

Django>=1.3,<1.4

Note: ordered operators work for your case after the change introduced in this commit in 2015

Ref: PEP 440 Inclusive ordered comparison

Ref: PEP 440 Exclusive ordered comparison


Synecdoche answered 24/2, 2023 at 12:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.