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
raise RuntimeError("Unable to find version string.")
20
+
While different projects have different needs, it's important to make sure that there is a single source of truth for the version number.
31
21
32
-
setup(
33
-
...
34
-
version=find_version("package", "__init__.py")
35
-
...
36
-
)
22
+
In general, the options are:
37
23
38
-
.. note::
24
+
1) If the code is in a version control system (VCS), e.g. git, then the version can be extracted from the VCS.
39
25
40
-
This technique has the disadvantage of having to deal with complexities of regular expressions.
26
+
2) The version can be hard-coded into the `pyproject.toml` file -- and the build system can copy it into other locations it may be required.
41
27
42
-
#. Use an external build tool that either manages updating both locations, or
43
-
offers an API that both locations can use.
28
+
3) The version string can be hard-coded into the source code -- either in a special purpose file, such as `_version.txt`, or as a attribute in the `__init__.py`, and the build system can extract it at build time.
44
29
45
-
Few tools you could use, in no particular order, and not necessarily complete:
0 commit comments