Set project version statically due to Hatchling limitation
Marco Ricci

Marco Ricci commited on 2024-07-14 13:14:10
Zeige 4 geänderte Dateien mit 4 Einfügungen und 4 Löschungen.


Hatch/Hatchling do not support reading the version string from (or
writing a new string to) multiple files.  See
[pypa/hatch#684](https://github.com/pypa/hatch/issues/684).  Until such
a feature is implemented, or I write my own script or hatchling plugin
to replicate the version number myself, set the number statically in the
project metadata, and forego the luxury of having the version number
available in source code form.  Users wanting the project version number
will need to query the package metadata, e.g. via
`importlib.metadata.version(...)` from the Python standard library.
... ...
@@ -4,7 +4,6 @@ build-backend = "hatchling.build"
4 4
 
5 5
 [project]
6 6
 name = "derivepassphrase"
7
-dynamic = ["version"]
8 7
 description = "An almost faithful Python reimplementation of James Coglan's vault."
9 8
 readme = "README.md"
10 9
 requires-python = ">=3.10"
... ...
@@ -28,6 +27,7 @@ dependencies = [
28 27
   "click>=8.1",
29 28
   "typing_extensions",
30 29
 ]
30
+version = "0.1.0c1"
31 31
 
32 32
 [project.optional-dependencies]
33 33
 dev = ["black", "coverage", "hatch>=1.10", "mkdocs", "mkdocs-material",
... ...
@@ -20,7 +20,7 @@ import sequin
20 20
 import ssh_agent_client
21 21
 
22 22
 __author__ = "Marco Ricci <m@the13thletter.info>"
23
-__version__ = "0.1.0"
23
+# Use importlib.metadata.version(...) to query the version.
24 24
 
25 25
 class AmbiguousByteRepresentationError(ValueError):
26 26
     """The object has an ambiguous byte representation."""
... ...
@@ -28,7 +28,7 @@ from typing_extensions import assert_type
28 28
 
29 29
 __all__ = ('Sequin', 'SequinExhaustedError')
30 30
 __author__ = 'Marco Ricci <m@the13thletter.info>'
31
-__version__ = "0.1.0"
31
+# Use importlib.metadata.version(...) to query the version.
32 32
 
33 33
 class Sequin:
34 34
     """Generate pseudorandom non-negative numbers in different ranges.
... ...
@@ -18,7 +18,7 @@ from ssh_agent_client import types
18 18
 
19 19
 __all__ = ('SSHAgentClient',)
20 20
 __author__ = 'Marco Ricci <m@the13thletter.info>'
21
-__version__ = "0.1.0"
21
+# Use importlib.metadata.version(...) to query the version.
22 22
 
23 23
 _socket = socket
24 24
 
25 25