You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/single_source_version.rst
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,9 @@ One of the challenges in building packages is that the version string can be req
12
12
* It needs to be specified when building the package (e.g. in :file:`pyproject.toml`)
13
13
- That will assure that it is properly assigned in the distribution file name, and in the installed package metadata.
14
14
15
-
* A package may set a top level ``__version__`` attribute to provide runtime access to the version of the imported package. If this is done, the value of ``__version__`` attribute and that used by the build system to set the distribution's version should be kept in sync in :ref:`the build systems's recommended way <how_to_set_version_links>`.
15
+
* A package may set a top level ``__version__`` attribute to provide runtime access to the version of the imported package. If this is done, the value of ``__version__`` attribute and that used by the build system to set the distribution's version should be kept in sync in :ref:`the build systems's recommended way <Build system version handling>`.
16
16
17
-
In the cases where a package does not set a top level ``__version__`` attribute, the version may still be accessible using ``importlib.metadata.version("distribution_name")``.
17
+
In any case, The installed distribution version should be accessible using ``importlib.metadata.version("distribution_name")``.
18
18
19
19
To ensure that version numbers do not get out of sync, it is recommended that there is a single source of truth for the version number.
20
20
@@ -29,11 +29,13 @@ In general, the options are:
29
29
30
30
Consult your build system's documentation for their recommended method.
31
31
32
-
.. _how_to_set_version_links:
32
+
.. _Build system version handling:
33
33
34
34
Build System Version Handling
35
35
-----------------------------
36
36
37
+
The following are links to some build system's documentation for handling version strings.
0 commit comments