Search code examples
pythonpipenv

Please explain version numbering in Pipfile


When working with Pipfile written by other developers, I found the following esoteric constructs:

  • package="~=3.4.2.17" What is the meaning of this? I assume, this does this mean, any version ever, just not 3.4.2.17?

  • package="==1.12.0" How does this differ from package="1.12.0" ?

And, in general, what is the right way to specify the version number or they range?

There is the dedicated git project https://github.com/pypa/pipfile, just for the Pipfile specification. It, however, does not explain these constructs.

It would be possible to assume that the specified values are just wrong. However pipenv swallows them without error messages, so this is probably unlikely.


Solution

  • The version description format is specified in PEP 440 — Version Identification and Dependency Specification.

    • ~=3.4.2.17 (a compatible release clause) means a version of 3.4.2.* which is greater than or equal to 3.4.2.17
    • ==1.12.0 (a version matching clause) does mean exactly version 1.12.0 but with some details about how wildcards work, which are explained in the PEP documentation.