Skip to content

Commit 0646aaa

Browse files
committed
Add section for versioning recommendations
1 parent e8b3eaa commit 0646aaa

File tree

1 file changed

+72
-11
lines changed

1 file changed

+72
-11
lines changed

source/distributing.rst

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,15 @@ version
166166

167167
version='1.2.0',
168168

169+
This is the current version of your project, allowing your users to determine whether or not
170+
they have the latest version, and to indicate which specific versions they've tested their own
171+
software against.
169172

170-
Projects should comply with the `version scheme
171-
<http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers>`_
172-
specified in :ref:`PEP440 <pypa:PEP440s>`. Here are some examples:
173+
Versions are displayed on :term:`PyPI <Python Package Index (PyPI)>` for each release if you
174+
publish your project.
173175

174-
::
175-
176-
1.2.0.dev1 # Development release
177-
1.2.0a1 # Alpha Release
178-
1.2.0b1 # Beta Release
179-
1.2.0rc1 # RC Release
180-
1.2.0 # Final Release
181-
1.2.0.post1 # Post Release
176+
See :ref:`Choosing a versioning scheme` for more information on ways to use versions to convey
177+
compatibility information to your users.
182178

183179
If the project code itself needs run-time access to the version, the simplest
184180
way is to keep the version in both ``setup.py`` and your code. If you'd rather
@@ -418,6 +414,71 @@ For more information, see `Automatic Script Creation
418414
<http://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation>`_
419415
from the `setuptools docs <http://pythonhosted.org/setuptools/setuptools.html>`_.
420416

417+
Choosing a versioning scheme
418+
----------------------------
419+
420+
Different Python projects may use different versioning schemes, but all of them will comply with the `public version scheme
421+
<https://www.python.org/dev/peps/pep-0440/#public-version-identifiers>`_ specified in :ref:`PEP440 <pypa:PEP440s>`. Here are some examples of compliant version numbers::
422+
423+
1.2.0.dev1 # Development release
424+
1.2.0a1 # Alpha Release
425+
1.2.0b1 # Beta Release
426+
1.2.0rc1 # Release Candidate
427+
1.2.0 # Final Release
428+
1.2.0.post1 # Post Release
429+
430+
Recommended versioning scheme
431+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432+
433+
For new projects, the recommended versioning scheme is based on `Semantic Versioning <http://semver.org>`_, but adopts a different approach to handling pre-releases and build metadata.
434+
435+
The essence of semantic versioning is a 3-part MAJOR.MINOR.MAINTENANCE numbering scheme, where the project author increments:
436+
437+
1. MAJOR version when they make incompatible API changes,
438+
2. MINOR version when they add functionality in a backwards-compatible manner, and
439+
3. MAINTENANCE version when they make backwards-compatible bug fixes.
440+
441+
Adopting this approach as a project author allows users to make use of `"compatible release" <https://www.python.org/dev/peps/pep-0440/#compatible-release>`_ specifiers, where ``name ~= X.Y`` requires at least release X.Y, but also allows any later release with a matching MAJOR version.
442+
443+
Python projects adopting semantic versioning should abide by clauses 1-8 of the `Semantic Versioning 2.0.0 specification <http://semver.org>`_.
444+
445+
Date based versioning
446+
*********************
447+
448+
Semantic versioning is not a suitable choice for all projects, such as those with a regular time based release cadence and a deprecation process that provides warnings for a number of releases prior to removal of a feature.
449+
450+
Version numbers for date based projects typically take the form of YEAR.MONTH (for example, ``12.04``, ``15.10``).
451+
452+
Serial versioning
453+
*****************
454+
455+
This is the simplest possible versioning scheme, and consists of a single number which is incremented every release.
456+
457+
While serial versioning is very easy to manage as a developer, it is the hardest to track as an end user, as serial version numbers convey little or no information regarding API backwards compatibility.
458+
459+
460+
Pre-release versioning
461+
~~~~~~~~~~~~~~~~~~~~~~
462+
463+
Regardless of the base versioning scheme, pre-releases for a given final release may be published as:
464+
465+
* zero or more dev releases (denoted with a ".devN" suffix)
466+
* zero or more alpha releases (denoted with a ".aN" suffix)
467+
* zero or more beta releases (denoted with a ".bN" suffix)
468+
* zero or more release candidates (denoted with a ".rcN" suffix)
469+
470+
``pip`` and other modern Python package installers ignore pre-releases by default when deciding which versions of dependencies to install.
471+
472+
473+
Local version identifiers
474+
~~~~~~~~~~~~~~~~~~~~~~~~~
475+
476+
Public version identifiers are designed to support distribution via :term:`PyPI <Python Package Index (PyPI)>`. Python's software distribution tools also support the notion of a `local version identifier <https://www.python.org/dev/peps/pep-0440/#local-version-identifiers>`_, which can be used to identify local development builds not intended for publication, or modified variants of a release maintained by a redistributor.
477+
478+
A local version identifier takes the form ``<public version identifier>+<local version label>``. For example::
479+
480+
1.2.0.dev1+hg.5.b11e5e6f0b0b # 5th VCS commmit since 1.2.0.dev1 release
481+
1.2.1+fedora.4 # Package with downstream Fedora patches applied
421482

422483

423484
Working in "Development Mode"

0 commit comments

Comments
 (0)