Search code examples
pythonpipsetuptoolssetup.pyrequirements.txt

Python `requirements.txt` and `setup.py` pick several ranges for the same package


I am developing 2 packages, package A that depends on package B. I am currently restricting the versioning of package B<2.0,>1.7 in the requirements.txt and setup.py of package A which works just fine.

The thing is that I have a way to publish internal beta versions with the version numbering 0.0bx where x is a random number. Is there a way to add a restriction to support this type of beta format? I tried setting B<2.0,>1.7,<0.1 but it produces the error ERROR: Cannot install -r /requirements.txt (line 1) and B==0.0b111 because these package versions have conflicting dependencies?


Solution

  • You say that you are publishing B with

    version numbering 0.0bx where x is a random number

    yet you also explain that that version numbering scheme is causing you interoperability grief.

    Consider adopting SemVer instead. You don't have to externally publish each of the minor / patch revs that you make available internally. There are advantages to using internal version numbers that are compatible with external ones. We have a version numbering scheme, it addresses certain use cases, and it serves both internal / external users. A scheme that doesn't meet current needs is one that is not fit for use.

    Suppose you cut a 3.2.1 release for external consumption. You might append a component and use 3.2.1.1 internally, or even append multiple components. Some folks put a date or build number into such components. Then strip them upon releasing 3.2.2 or 3.3.0 or 4.0.0.