Skip to content Skip to sidebar Skip to footer

What Is The Purpose Of Setuptools Requirements Of The Form "package===version"

Say I have a package with a console script such as from setuptools import setup setup( name='eg_package', version='0.0.1', description='Trivial test package', packa

Solution 1:

Requirement specifier section in pip docs links to the official docs for requirement specifiers implemented by setuptoolspkg_resources. It specifies the formal syntax but says nothing on the semantics. Overview docs explain semantics but say nothing on the ~= and === stuff that were apparently added somewhere between vv.7 (installed with python 2.7.9) and 16.

When docs fail, it's time to consult the sources. Downloading the setuptools hg repo and annotating pkg_resources/__init__.py ultimately brings us to changeset 3125 with the message "Implement PEP 440 by using the packaging library".

Indeed, PEP 440, Version Specifiers section explains the syntax and semantics:

By examining other files in the commit and the related packaging package, I came to these apparent conclusions:

  • ~= is never produced; when handled, it acts as a filter according to the rules outlined in the PEP.
  • ===, when handled, signals to fall back to the older setuptools version syntax and comparison logic. It is produced whenever the resulting version string doesn't conform to the PEP.

In pkg_resources._vendor.packaging.specifiers._compare_compatible()pkg_resources.parse_version() produces a pkg_resources.SetuptoolsLegacyVersion rather than pkg_resources.SetuptoolsVersion

Post a Comment for "What Is The Purpose Of Setuptools Requirements Of The Form "package===version""