@@ -18,27 +18,47 @@ version identifiers, for which the authoritative reference is the
1818:ref: `specification of version specifiers <version-specifiers >`. Here are some
1919examples of version numbers:
2020
21- .. code-block :: text
22-
23- 1.2.0.dev1 # Development release
24- 1.2.0a1 # Alpha Release
25- 1.2.0b1 # Beta Release
26- 1.2.0rc1 # Release Candidate
27- 1.2.0 # Final Release
28- 1.2.0.post1 # Post Release
29- 15.10 # Date based release
30- 23 # Serial release
21+ - A simple version (final release): 1.2.0
22+ - A development release: 1.2.0.dev1
23+ - An alpha release: 1.2.0a1
24+ - A beta release: 1.2.0b1
25+ - A release candidate: 1.2.0rc1
26+ - A post-release: 1.2.0.post1
27+ - A post-release of an alpha release (possible, but discouraged): 1.2.0a1.post1
28+ - A simple version with only two components: 23.12
29+ - A simple version with just one component (possible, but discouraged): 42
30+ - A version with an epoch: 1!1.0
31+
32+ Projects can use a cycle of pre-releases to support testing by their users
33+ before a final release. In order, the steps are: alpha releases, beta releases,
34+ release candidates, final release.
35+
36+ The purpose of development releases is to support releases made early during a
37+ development cycle, for example, a nightly build, or a build from the latest
38+ source in a Linux distribution.
39+
40+ Post-releases are used to address minor errors in a final release that do not
41+ affect the distributed software, such as correcting an error in the release
42+ notes. They should not be used for bug fixes; these should be done with a new
43+ final release (e.g., incrementing the third component when using semantic
44+ versioning).
45+
46+ Finally, epochs, a rarely used feature, serve to fix the sorting order when
47+ changing the versioning scheme. For example, if a project is using calendar
48+ versioning, with versions like 23.12, and switches to semantic versioning, with
49+ versions like 1.0, the comparison between 1.0 and 23.12 will go the wrong way.
50+ To correct this, the new version numbers should have an explicit epoch, as in
51+ "1!1.0", in order to be treated as more recent than the old version numbers.
3152
3253
3354Semantic versioning vs. calendar versioning
3455===========================================
3556
36- A versioning scheme is a way to interpret version numbers of a package, and to
37- decide which should be the next version number for a new release of a package.
38- Two versioning schemes are commonly used for Python packages, semantic
39- versioning and calendar versioning.
57+ A versioning scheme is a formalized way to interpret the segments of a version
58+ number, and to decide which should be the next version number for a new release
59+ of a package. Two versioning schemes are commonly used for Python packages,
60+ semantic versioning and calendar versioning.
4061
41- Semantic versioning is recommended for most new projects.
4262
4363Semantic versioning
4464-------------------
@@ -50,14 +70,15 @@ The idea of *semantic versioning* is to use 3-part version numbers,
5070- *minor * when they add functionality in a backwards-compatible manner, and
5171- *maintenance *, when they make backwards-compatible bug fixes.
5272
53- Note that many projects, especially larger ones, do not use strict semantic
54- versioning since many changes are technically breaking changes but affect only a
55- small fraction of users. Such projects tend to increment the major number when
56- the incompatibility is high, rather than for any tiny incompatibility, or to
57- signal a shift in the project.
73+ A majority of Python projects use a scheme that resembles semantic
74+ versioning. However, most projects, especially larger ones, do not strictly
75+ adhere to semantic versioning, since many changes are technically breaking
76+ changes but affect only a small fraction of users. Such projects tend to
77+ increment the major number when the incompatibility is high, or to signal a
78+ shift in the project, rather than for any tiny incompatibility,
5879
59- For those projects that do adhere to semantic versioning strictly , this approach
60- allows users to make use of :ref: `compatible release version specifiers
80+ For those projects that do use strict semantic versioning, this approach allows
81+ users to make use of :ref: `compatible release version specifiers
6182<version-specifiers-compatible-release>`, with the ``~= `` operator. For
6283example, ``name ~= X.Y `` is roughly equivalent to ``name >= X.Y, == X.* ``, i.e.,
6384it requires at least release X.Y, and allows any later release with greater Y as
@@ -68,6 +89,13 @@ release with same X and Y but higher Z.
6889Python projects adopting semantic versioning should abide by clauses 1-8 of the
6990`Semantic Versioning 2.0.0 specification <semver _>`_.
7091
92+ The popular :doc: `Sphinx <sphinx:index >` documentation generator is an example
93+ project that uses strict semantic versioning (:doc: `Sphinx versioning policy
94+ <sphinx:internals/release-process>`). The famous :doc: `NumPy <numpy:index >`
95+ scientific computing package explicitly uses "loose" semantic versioning, where
96+ releases incrementing the minor version can contain backwards-incompatible API
97+ changes (:doc: `NumPy versioning policy <numpy:dev/depending_on_numpy >`).
98+
7199
72100Calendar versioning
73101-------------------
@@ -81,7 +109,10 @@ is that it is straightforward to tell how old the base feature set of a
81109particular release is given just the version number.
82110
83111Calendar version numbers typically take the form *year.month * (for example,
84- 23.10 for December 2023).
112+ 23.12 for December 2023).
113+
114+ :doc: `Pip <pip:index >`, the standard Python package installer, uses calendar
115+ versioning.
85116
86117
87118Other schemes
@@ -107,12 +138,13 @@ Regardless of the base versioning scheme, pre-releases for a given final release
107138may be published as:
108139
109140* Zero or more dev releases, denoted with a ".devN" suffix,
110- * Zero or more alpha releases, denoted with a ". aN" suffix,
111- * Zero or more beta releases, denoted with a ". bN" suffix,
112- * Zero or more release candidates, denoted with a ". rcN" suffix.
141+ * Zero or more alpha releases, denoted with a "aN" suffix,
142+ * Zero or more beta releases, denoted with a "bN" suffix,
143+ * Zero or more release candidates, denoted with a "rcN" suffix.
113144
114145Pip and other modern Python package installers ignore pre-releases by default
115- when deciding which versions of dependencies to install.
146+ when deciding which versions of dependencies to install, unless explicitly
147+ requested, e.g., with ``pip install pkg==1.1a3 ``.
116148
117149
118150Local version identifiers
@@ -125,15 +157,15 @@ used to identify local development builds not intended for publication, or
125157modified variants of a release maintained by a redistributor.
126158
127159A local version identifier takes the form of a public version identifier,
128- followed by "+" and a local version label. For example:
129-
130- .. code-block :: text
131-
132- 1.2.0.dev1+hg.5.b11e5e6f0b0b # 5th VCS commit since 1.2.0.dev1 release
133- 1.2.1+fedora.4 # Package with downstream Fedora patches applied
134-
135-
160+ followed by "+" and a local version label. For example, a package with
161+ Fedora-specific patches applied could have the version "1.2.1+fedora.4".
162+ Another example is versions computed by setuptools-scm _, a setuptools plugin
163+ that reads the version from Git data. In a Git repository with some commits
164+ since the latest release, setuptools-scm generates a version like
165+ "0.5.dev1+gd00980f", or if the repository has untracked changes, like
166+ "0.5.dev1+gd00980f.d20231217".
136167
137168
138169.. _calver : https://calver.org
139170.. _semver : https://semver.org
171+ .. _setuptools-scm : https://setuptools-scm.readthedocs.io
0 commit comments