@@ -18,27 +18,47 @@ version identifiers, for which the authoritative reference is the
18
18
:ref: `specification of version specifiers <version-specifiers >`. Here are some
19
19
examples of version numbers:
20
20
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.
31
52
32
53
33
54
Semantic versioning vs. calendar versioning
34
55
===========================================
35
56
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.
40
61
41
- Semantic versioning is recommended for most new projects.
42
62
43
63
Semantic versioning
44
64
-------------------
@@ -50,14 +70,15 @@ The idea of *semantic versioning* is to use 3-part version numbers,
50
70
- *minor * when they add functionality in a backwards-compatible manner, and
51
71
- *maintenance *, when they make backwards-compatible bug fixes.
52
72
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,
58
79
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
61
82
<version-specifiers-compatible-release>`, with the ``~= `` operator. For
62
83
example, ``name ~= X.Y `` is roughly equivalent to ``name >= X.Y, == X.* ``, i.e.,
63
84
it 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.
68
89
Python projects adopting semantic versioning should abide by clauses 1-8 of the
69
90
`Semantic Versioning 2.0.0 specification <semver _>`_.
70
91
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
+
71
99
72
100
Calendar versioning
73
101
-------------------
@@ -81,7 +109,10 @@ is that it is straightforward to tell how old the base feature set of a
81
109
particular release is given just the version number.
82
110
83
111
Calendar 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.
85
116
86
117
87
118
Other schemes
@@ -107,12 +138,13 @@ Regardless of the base versioning scheme, pre-releases for a given final release
107
138
may be published as:
108
139
109
140
* 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.
113
144
114
145
Pip 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 ``.
116
148
117
149
118
150
Local version identifiers
@@ -125,15 +157,15 @@ used to identify local development builds not intended for publication, or
125
157
modified variants of a release maintained by a redistributor.
126
158
127
159
A 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".
136
167
137
168
138
169
.. _calver : https://calver.org
139
170
.. _semver : https://semver.org
171
+ .. _setuptools-scm : https://setuptools-scm.readthedocs.io
0 commit comments