Python's pip
and easy_install
follow some rules to sort packages by their release numbers. What are the rules for numbering beta/release/bugfix releases so these tools will know which is the newest?
views:
81answers:
3See the documentation or look at the source: doc string in pkg_resources.py function parse_version().
This is a sore point for many folks. setuptools
and easy_install
have some rather bizarre rules in an attempt to play nice with everybody. You can read the full rules in setuptools
's parse_version
method, but here's the summary:
Version numbers are broken up by dots into a tuple of that many segments. 4.5.6.7 is parsed into a tuple equal to
("4", "5", "6", "7")
.Trailing zeroes between dashes or alphanumerics are suppressed. 2.4.0 is the same as 2.4; 2.4.05 is the same as 2.4.5.
Alphanumeric parts are downcased. 2.4.a5 is equal to 2.4.A5.
Strings that come before "final" alphabetically are assumed to be pre-release versions, so 2.4.5b comes before, not after, 2.4.5.
Finally, "pre", "preview", and "rc" are treated as if they were "c". The word "dev" is replaced with "@", so that it comes before anything else with the same version. That is,
x.y.z-dev
is guaranteed to come before any otherx.y.z
version.
There are a number of proposals to organize things a bit more, of which the most popular is probably PEP 386.
Use 1.0a1 and 1.0b2 before 1.0.
The upcoming standard:
- http://www.python.org/dev/peps/pep-0386/#the-new-versioning-algorithm
- http://tarekziade.wordpress.com/2009/11/18/distutils-and-distribute-status-part-1/
- http://bitbucket.org/tarek/distutilsversion/
Current setuptools: http://peak.telecommunity.com/DevCenter/setuptools#specifying-your-project-s-version