73

I have this line in my requirements file

django>=1.10,<1.11

Does that mean I need to have Django version >= 1.10 and then less than 1.11?

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
Chris
  • 4,643
  • 6
  • 31
  • 49

1 Answers1

96

Yes. The pip manual [doc] has a section on the format of "requirement specifiers". These are documented in PEP-508 [pep] and PEP-440 [pep]:

The comparison operator determines the kind of version clause:

  1. ~=: Compatible release clause
  2. ==: Version matching clause
  3. !=: Version exclusion clause
  4. <=, >=: Inclusive ordered comparison clause
  5. <, >: Exclusive ordered comparison clause
  6. ===: Arbitrary equality clause.

The comma (",") is equivalent to a logical and operator: a candidate version must match all given version clauses in order to match the specifier as a whole.

So in your case it means that the Django version is 1.10 or higher and not 1.11 or higher (so 1.10 is fine, 1.10.1, as well, but not 1.11, 1.11.1, or 2.0.1).

Yogev Neumann
  • 2,099
  • 2
  • 13
  • 24
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
  • 1
    Is there any way to say "any version except for this range"? In other words, how would I say [`setuptools` version `<45.0.0` *or* `>=49.9.1`](https://github.com/pypa/setuptools/issues/1963)> – Jonathon Reinhart Jul 23 '20 at 23:37
  • 1
    @JonathonReinhart: not as far as I know nu, especially since there is no disjunction (logical or). You can do this with `!= 45.*, != 46.*, !=47.*, !=48.*, !=49.1.*, !=49.1.*, !=49.2.*, !=49.3.*, !=49.4.*, !=49.5.*, !=49.6.*, !=49.7.*, !=49.8.*, !=49.9.0.*` – Willem Van Onsem Jul 23 '20 at 23:45
  • I came to the same unfortunate conclusion. Luckily, I made a typo and the range is `49.1.1` (not `49.9.1`). So I used this: `setuptools !=45.*, !=46.*, !=47.*, !=48.*, !=49.1.0`. Thanks! – Jonathon Reinhart Jul 23 '20 at 23:59