Specify project dependencies more clearly and explicitly
Marco Ricci

Marco Ricci commited on 2024-08-17 01:09:23
Zeige 1 geänderte Dateien mit 26 Einfügungen und 6 Löschungen.


Use proper syntax for dependency version specification (spaces, and
compatible release operator).  If sensible, add a comment as to why we
have this dependency, and why at that version.  Furthermore, for hatch
environments, make use of environment inheritance, and move the
dependencies to the correct environments instead of collecting them all
in the "dev" extra.
... ...
@@ -24,14 +24,22 @@ classifiers = [
24 24
   "Programming Language :: Python :: Implementation :: PyPy",
25 25
 ]
26 26
 dependencies = [
27
+  # We use click for the command-line interface.  We require version 8.1.0
28
+  # or higher due to click issue #1985.
27 29
   "click >= 8.1",
30
+  # We include type annotations, and use facilities that are not readily
31
+  # available in older Pythons (such as typing.Self).  These are loaded from
32
+  # typing_extensions, instead of using explicit version guards.
28 33
   "typing_extensions",
29 34
 ]
30 35
 version = "0.1.3"
31 36
 
32 37
 [project.optional-dependencies]
33
-dev = ["black", "coverage", "hatch>=1.10", "mkdocs", "mkdocs-material",
34
-       "mkdocstrings[python]", "pytest>=8.1", "towncrier>=23.11"]
38
+dev = [
39
+  # Development uses the hatch build system, to isolate all tools in their
40
+  # own virtual environment.
41
+  "hatch ~= 1.10",
42
+]
35 43
 
36 44
 [project.scripts]
37 45
 derivepassphrase = "derivepassphrase.cli:derivepassphrase"
... ...
@@ -87,6 +95,13 @@ requires = [
87 95
 [tool.hatch.env.collectors.mkdocs.docs]
88 96
 path = "mkdocs.yml"
89 97
 
98
+[tool.hatch.envs.default-test]
99
+dependencies = [
100
+  "coverage[toml] ~= 7.5",
101
+  "pytest ~= 8.1",
102
+  "pytest-randomly ~= 3.15",
103
+]
104
+
90 105
 [tool.hatch.envs.docs]
91 106
 extra-dependencies = [
92 107
   # Our documentation uses the Material theme.  It also uses
... ...
@@ -105,7 +120,9 @@ detached = false
105 120
 
106 121
 [tool.hatch.envs.hatch-static-analysis]
107 122
 config-path = "ruff_defaults_v0.5.0.toml"
108
-dependencies = ["ruff==0.5.0"]
123
+dependencies = [
124
+  "ruff ~= 0.5.0"
125
+]
109 126
 
110 127
 [tool.hatch.envs.hatch-test]
111 128
 default-args = ['src', 'tests']
... ...
@@ -114,15 +131,18 @@ default-args = ['src', 'tests']
114 131
 python = ["3.10", "3.11", "3.12", "pypy3.10"]
115 132
 
116 133
 [tool.hatch.envs.release]
117
-dependencies = ['towncrier>=23.11']
134
+extra-dependencies = [
135
+  "towncrier >= 23.11"
136
+]
118 137
 
119 138
 [tool.hatch.envs.release.scripts]
120 139
 
121 140
 [tool.hatch.envs.types]
122 141
 extra-dependencies = [
123
-  "mypy>=1.0.0",
124
-  "pytest~=8.1",
142
+  "mypy ~= 1.0",
125 143
 ]
144
+template = "default-test"
145
+
126 146
 [tool.hatch.envs.types.scripts]
127 147
 check = "mypy --install-types --non-interactive {args:src/derivepassphrase tests}"
128 148
 
129 149