pydantic_espresso 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. pydantic_espresso-0.0.1/LICENSE +21 -0
  2. pydantic_espresso-0.0.1/PKG-INFO +428 -0
  3. pydantic_espresso-0.0.1/README.md +388 -0
  4. pydantic_espresso-0.0.1/pyproject.toml +304 -0
  5. pydantic_espresso-0.0.1/src/pydantic_espresso/__init__.py +4 -0
  6. pydantic_espresso-0.0.1/src/pydantic_espresso/__main__.py +12 -0
  7. pydantic_espresso-0.0.1/src/pydantic_espresso/base.py +47 -0
  8. pydantic_espresso-0.0.1/src/pydantic_espresso/cli.py +106 -0
  9. pydantic_espresso-0.0.1/src/pydantic_espresso/def2xml.py +71 -0
  10. pydantic_espresso-0.0.1/src/pydantic_espresso/def2xml.sh +40 -0
  11. pydantic_espresso-0.0.1/src/pydantic_espresso/def_files/__init__.py +5 -0
  12. pydantic_espresso-0.0.1/src/pydantic_espresso/errors.py +232 -0
  13. pydantic_espresso-0.0.1/src/pydantic_espresso/fetch.py +99 -0
  14. pydantic_espresso-0.0.1/src/pydantic_espresso/models/__init__.py +70 -0
  15. pydantic_espresso-0.0.1/src/pydantic_espresso/models/all_currents/__init__.py +1 -0
  16. pydantic_espresso-0.0.1/src/pydantic_espresso/models/all_currents/develop.py +227 -0
  17. pydantic_espresso-0.0.1/src/pydantic_espresso/models/band_interpolation/__init__.py +1 -0
  18. pydantic_espresso-0.0.1/src/pydantic_espresso/models/band_interpolation/develop.py +87 -0
  19. pydantic_espresso-0.0.1/src/pydantic_espresso/models/bands/__init__.py +1 -0
  20. pydantic_espresso-0.0.1/src/pydantic_espresso/models/bands/develop.py +115 -0
  21. pydantic_espresso-0.0.1/src/pydantic_espresso/models/bgw2pw/__init__.py +1 -0
  22. pydantic_espresso-0.0.1/src/pydantic_espresso/models/bgw2pw/develop.py +64 -0
  23. pydantic_espresso-0.0.1/src/pydantic_espresso/models/cp/__init__.py +1 -0
  24. pydantic_espresso-0.0.1/src/pydantic_espresso/models/cp/develop.py +1719 -0
  25. pydantic_espresso-0.0.1/src/pydantic_espresso/models/cppp/__init__.py +1 -0
  26. pydantic_espresso-0.0.1/src/pydantic_espresso/models/cppp/develop.py +135 -0
  27. pydantic_espresso-0.0.1/src/pydantic_espresso/models/d3hess/__init__.py +1 -0
  28. pydantic_espresso-0.0.1/src/pydantic_espresso/models/d3hess/develop.py +50 -0
  29. pydantic_espresso-0.0.1/src/pydantic_espresso/models/dos/__init__.py +1 -0
  30. pydantic_espresso-0.0.1/src/pydantic_espresso/models/dos/develop.py +96 -0
  31. pydantic_espresso-0.0.1/src/pydantic_espresso/models/dynmat/__init__.py +1 -0
  32. pydantic_espresso-0.0.1/src/pydantic_espresso/models/dynmat/develop.py +135 -0
  33. pydantic_espresso-0.0.1/src/pydantic_espresso/models/hp/__init__.py +1 -0
  34. pydantic_espresso-0.0.1/src/pydantic_espresso/models/hp/develop.py +318 -0
  35. pydantic_espresso-0.0.1/src/pydantic_espresso/models/kcw/__init__.py +1 -0
  36. pydantic_espresso-0.0.1/src/pydantic_espresso/models/kcw/cards/__init__.py +9 -0
  37. pydantic_espresso-0.0.1/src/pydantic_espresso/models/kcw/develop.py +383 -0
  38. pydantic_espresso-0.0.1/src/pydantic_espresso/models/ld1/__init__.py +1 -0
  39. pydantic_espresso-0.0.1/src/pydantic_espresso/models/ld1/develop.py +566 -0
  40. pydantic_espresso-0.0.1/src/pydantic_espresso/models/matdyn/__init__.py +1 -0
  41. pydantic_espresso-0.0.1/src/pydantic_espresso/models/matdyn/develop.py +261 -0
  42. pydantic_espresso-0.0.1/src/pydantic_espresso/models/molecularpdos/__init__.py +1 -0
  43. pydantic_espresso-0.0.1/src/pydantic_espresso/models/molecularpdos/develop.py +148 -0
  44. pydantic_espresso-0.0.1/src/pydantic_espresso/models/neb/__init__.py +1 -0
  45. pydantic_espresso-0.0.1/src/pydantic_espresso/models/neb/develop.py +10 -0
  46. pydantic_espresso-0.0.1/src/pydantic_espresso/models/oscdft_et/__init__.py +1 -0
  47. pydantic_espresso-0.0.1/src/pydantic_espresso/models/oscdft_et/develop.py +43 -0
  48. pydantic_espresso-0.0.1/src/pydantic_espresso/models/oscdft_pp/__init__.py +1 -0
  49. pydantic_espresso-0.0.1/src/pydantic_espresso/models/oscdft_pp/develop.py +26 -0
  50. pydantic_espresso-0.0.1/src/pydantic_espresso/models/ph/__init__.py +1 -0
  51. pydantic_espresso-0.0.1/src/pydantic_espresso/models/ph/develop.py +623 -0
  52. pydantic_espresso-0.0.1/src/pydantic_espresso/models/postahc/__init__.py +1 -0
  53. pydantic_espresso-0.0.1/src/pydantic_espresso/models/postahc/develop.py +130 -0
  54. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pp/__init__.py +1 -0
  55. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pp/develop.py +548 -0
  56. pydantic_espresso-0.0.1/src/pydantic_espresso/models/ppacf/__init__.py +1 -0
  57. pydantic_espresso-0.0.1/src/pydantic_espresso/models/ppacf/develop.py +110 -0
  58. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pprism/__init__.py +1 -0
  59. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pprism/develop.py +285 -0
  60. pydantic_espresso-0.0.1/src/pydantic_espresso/models/projwfc/__init__.py +1 -0
  61. pydantic_espresso-0.0.1/src/pydantic_espresso/models/projwfc/develop.py +146 -0
  62. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/__init__.py +1 -0
  63. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/__init__.py +73 -0
  64. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/atomic_forces.py +26 -0
  65. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/atomic_positions.py +135 -0
  66. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/atomic_species.py +30 -0
  67. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/atomic_velocities.py +28 -0
  68. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/cell_parameters.py +72 -0
  69. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/constraints.py +86 -0
  70. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/hubbard.py +92 -0
  71. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/k_points.py +132 -0
  72. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/occupations.py +10 -0
  73. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/cards/solvents.py +70 -0
  74. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw/develop.py +2803 -0
  75. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw2bgw/__init__.py +1 -0
  76. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw2bgw/develop.py +304 -0
  77. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw2gw/__init__.py +1 -0
  78. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw2gw/develop.py +87 -0
  79. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw2wannier90/__init__.py +1 -0
  80. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw2wannier90/develop.py +268 -0
  81. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw_with_os_cdft/__init__.py +1 -0
  82. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pw_with_os_cdft/develop.py +239 -0
  83. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pwcond/__init__.py +1 -0
  84. pydantic_espresso-0.0.1/src/pydantic_espresso/models/pwcond/develop.py +202 -0
  85. pydantic_espresso-0.0.1/src/pydantic_espresso/models/q2r/__init__.py +1 -0
  86. pydantic_espresso-0.0.1/src/pydantic_espresso/models/q2r/develop.py +72 -0
  87. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_davidson/__init__.py +1 -0
  88. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_davidson/develop.py +308 -0
  89. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_eels/__init__.py +1 -0
  90. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_eels/develop.py +216 -0
  91. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_lanczos/__init__.py +1 -0
  92. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_lanczos/develop.py +247 -0
  93. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_magnon/__init__.py +1 -0
  94. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_magnon/develop.py +142 -0
  95. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_spectrum/__init__.py +1 -0
  96. pydantic_espresso-0.0.1/src/pydantic_espresso/models/turbo_spectrum/develop.py +157 -0
  97. pydantic_espresso-0.0.1/src/pydantic_espresso/models/wannier2pw/__init__.py +1 -0
  98. pydantic_espresso-0.0.1/src/pydantic_espresso/models/wannier2pw/develop.py +73 -0
  99. pydantic_espresso-0.0.1/src/pydantic_espresso/namelist.py +36 -0
  100. pydantic_espresso-0.0.1/src/pydantic_espresso/py.typed +1 -0
  101. pydantic_espresso-0.0.1/src/pydantic_espresso/quantity.py +63 -0
  102. pydantic_espresso-0.0.1/src/pydantic_espresso/utils.py +28 -0
  103. pydantic_espresso-0.0.1/src/pydantic_espresso/version.py +39 -0
  104. pydantic_espresso-0.0.1/src/pydantic_espresso/xml2pydantic.py +2113 -0
  105. pydantic_espresso-0.0.1/src/pydantic_espresso/xml_files/__init__.py +5 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Edward Linscott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,428 @@
1
+ Metadata-Version: 2.4
2
+ Name: pydantic_espresso
3
+ Version: 0.0.1
4
+ Summary: Pydantic models for Quantum ESPRESSO
5
+ Keywords: snekpack,cookiecutter
6
+ Author: Edward Linscott
7
+ Author-email: Edward Linscott <edwardlinscott@gmail.com>
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 1 - Planning
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Framework :: tox
16
+ Classifier: Framework :: Sphinx
17
+ Classifier: Natural Language :: English
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Typing :: Typed
25
+ Requires-Dist: pydantic
26
+ Requires-Dist: packaging
27
+ Requires-Dist: click ; extra == 'dev'
28
+ Requires-Dist: python-gitlab ; extra == 'dev'
29
+ Requires-Dist: defusedxml>=0.7.1 ; extra == 'dev'
30
+ Maintainer: Edward Linscott
31
+ Maintainer-email: Edward Linscott <edwardlinscott@gmail.com>
32
+ Requires-Python: >=3.10
33
+ Project-URL: Bug Tracker, https://github.com/elinscott/pydantic-espresso/issues
34
+ Project-URL: Homepage, https://github.com/elinscott/pydantic-espresso
35
+ Project-URL: Repository, https://github.com/elinscott/pydantic-espresso.git
36
+ Project-URL: Documentation, https://pydantic_espresso.readthedocs.io
37
+ Project-URL: Funding, https://github.com/sponsors/elinscott
38
+ Provides-Extra: dev
39
+ Description-Content-Type: text/markdown
40
+
41
+ <!--
42
+ <p align="center">
43
+ <img src="https://github.com/elinscott/pydantic-espresso/raw/main/docs/source/logo.png" height="150">
44
+ </p>
45
+ -->
46
+
47
+ <h1 align="center">
48
+ pydantic-espresso
49
+ </h1>
50
+
51
+ <p align="center">
52
+ <a href="https://github.com/elinscott/pydantic-espresso/actions/workflows/tests.yml">
53
+ <img alt="Tests" src="https://github.com/elinscott/pydantic-espresso/actions/workflows/tests.yml/badge.svg" /></a>
54
+ <a href="https://pypi.org/project/pydantic_espresso">
55
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/pydantic_espresso" /></a>
56
+ <a href="https://pypi.org/project/pydantic_espresso">
57
+ <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/pydantic_espresso" /></a>
58
+ <a href="https://github.com/elinscott/pydantic-espresso/blob/main/LICENSE">
59
+ <img alt="PyPI - License" src="https://img.shields.io/pypi/l/pydantic_espresso" /></a>
60
+ <a href='https://pydantic_espresso.readthedocs.io/en/latest/?badge=latest'>
61
+ <img src='https://readthedocs.org/projects/pydantic_espresso/badge/?version=latest' alt='Documentation Status' /></a>
62
+ <a href="https://codecov.io/gh/elinscott/pydantic-espresso/branch/main">
63
+ <img src="https://codecov.io/gh/elinscott/pydantic-espresso/branch/main/graph/badge.svg" alt="Codecov status" /></a>
64
+ <a href="https://github.com/cthoyt/cookiecutter-python-package">
65
+ <img alt="Cookiecutter template from @cthoyt" src="https://img.shields.io/badge/Cookiecutter-snekpack-blue" /></a>
66
+ <a href="https://github.com/astral-sh/ruff">
67
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff" style="max-width:100%;"></a>
68
+ <a href="https://github.com/elinscott/pydantic-espresso/blob/main/.github/CODE_OF_CONDUCT.md">
69
+ <img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Contributor Covenant"/></a>
70
+ <!-- uncomment if you archive on zenodo
71
+ <a href="https://zenodo.org/badge/latestdoi/XXXXXX">
72
+ <img src="https://zenodo.org/badge/XXXXXX.svg" alt="DOI"></a>
73
+ -->
74
+ </p>
75
+
76
+ Pydantic models for `Quantum ESPRESSO`.
77
+
78
+ The models are auto-generated from the `INPUT_*.def` files shipped with
79
+ Quantum ESPRESSO. Supported QE versions are 7.6 and newer (the schema for
80
+ older releases lacks the structured `<units>`, `<dimensionality>`, and
81
+ `<default kind="...">` metadata that the generator depends on).
82
+
83
+ ## 💪 Getting Started
84
+
85
+ ```python
86
+ from pydantic_espresso.models.pw.develop import PWInput
87
+
88
+ inp = PWInput(
89
+ system={"ibrav": 0, "nat": 1, "ntyp": 1, "ecutwfc": 30.0},
90
+ cell_parameters={"unit": "alat", "vectors": [[1, 0, 0], [0, 1, 0], [0, 0, 1]]},
91
+ atomic_positions={
92
+ "unit": "alat",
93
+ "positions": [{"species": "H", "position": [0.0, 0.0, 0.0]}],
94
+ },
95
+ k_points={"kind": "gamma"},
96
+ )
97
+
98
+ # Pydantic enforces both the QE input schema and the field constraints:
99
+ inp.system.ibrav = -1 # ValidationError: invalid Bravais lattice index
100
+ inp.system.nbnd = "a" # ValidationError: not an int
101
+ inp.control.calculation = "bands" # OK
102
+ ```
103
+
104
+ Each numeric field carries its physical units and dimensionality as
105
+ `Quantity` metadata, threaded into both the pydantic field info and the
106
+ JSON schema:
107
+
108
+ ```python
109
+ from pydantic_espresso.models.pw.develop import SystemNamelist
110
+ from pydantic_espresso.quantity import quantity_for
111
+
112
+ q = quantity_for(SystemNamelist.model_fields["ecutwfc"])
113
+ # Quantity(units='Ry', dimensionality='energy')
114
+
115
+ PWInput.model_json_schema()["$defs"]["SystemNamelist"]["properties"]["ecutwfc"]
116
+ # {'type': 'number', 'units': 'Ry', 'dimensionality': 'energy', ...}
117
+ ```
118
+
119
+ QE namelist branches with mutually-exclusive layouts (e.g. PP's `PLOT`
120
+ namelist discriminated on `iflag`) are exposed as pydantic discriminated
121
+ unions, so the right variant is picked automatically from the input data.
122
+
123
+ ### Readable error reports
124
+
125
+ Construction raises a standard `pydantic.ValidationError`. Pass the caught
126
+ error to `pydantic_espresso.errors.explain` for a grouped, recursive summary
127
+ that names each missing input together with its type, units, and help text:
128
+
129
+ ```python
130
+ from pydantic import ValidationError
131
+ from pydantic_espresso.errors import explain
132
+ from pydantic_espresso.models.pw.develop import PWInput
133
+
134
+ try:
135
+ inp = PWInput(
136
+ system={"ibrav": 0, "ecutwfc": 30.0}, # missing nat, ntyp
137
+ cell_parameters={"vectors": [[1, 0, 0], [0, 1, 0], [0, 0, 1]]}, # missing 'unit'
138
+ k_points={"kind": "automatic"}, # missing grid
139
+ # atomic_positions omitted entirely
140
+ )
141
+ except ValidationError as exc:
142
+ print(explain(exc, PWInput))
143
+ ```
144
+
145
+ ```text
146
+ PWInput is missing required inputs:
147
+ system:
148
+ - nat (int): number of atoms in the unit cell (ALL atoms, except if space_group is set, in
149
+ which case, INEQUIVALENT atoms)
150
+ - ntyp (int): number of types of atoms in the unit cell
151
+ atomic_positions: required — choose 'unit': ['alat', 'bohr', 'angstrom', 'crystal', 'crystal_sg']
152
+ k_points [kind='automatic']:
153
+ - grid (tuple[int, int, int]): Monkhorst-Pack mesh dimensions (nk1, nk2, nk3): number of
154
+ k-points along each reciprocal-lattice direction of the uniform grid.
155
+ cell_parameters: missing discriminator 'unit' (one of ['alat', 'bohr', 'angstrom'])
156
+ ```
157
+
158
+ ### Command Line Interface
159
+
160
+ The `pydantic_espresso` command line tool ships with the package but requires
161
+ the optional `dev` extra (which pulls in `click`, `python-gitlab`, and
162
+ `defusedxml`). Install it with `pip install pydantic_espresso[dev]` or
163
+ `uv pip install "pydantic_espresso[dev]"`.
164
+
165
+ It can be used from the console with the `--help` flag to show all subcommands:
166
+
167
+ ```console
168
+ $ pydantic_espresso --help
169
+ ```
170
+
171
+ The JSON schema for `pw.x` can be generated with the command
172
+
173
+ ```console
174
+ $ pydantic_espresso schema pw
175
+ ```
176
+
177
+ ## 🚀 Installation
178
+
179
+ <!-- Uncomment this section after your first ``tox -e finish``
180
+ The most recent release can be installed from
181
+ [PyPI](https://pypi.org/project/pydantic_espresso/) with uv:
182
+
183
+ ```console
184
+ $ uv pip install pydantic_espresso
185
+ ```
186
+
187
+ or with pip:
188
+
189
+ ```console
190
+ $ python3 -m pip install pydantic_espresso
191
+ ```
192
+ -->
193
+
194
+ The most recent code and data can be installed directly from GitHub with uv:
195
+
196
+ ```console
197
+ $ uv pip install git+https://github.com/elinscott/pydantic-espresso.git
198
+ ```
199
+
200
+ or with pip:
201
+
202
+ ```console
203
+ $ python3 -m pip install git+https://github.com/elinscott/pydantic-espresso.git
204
+ ```
205
+
206
+ ## 👐 Contributing
207
+
208
+ Contributions, whether filing an issue, making a pull request, or forking, are
209
+ appreciated. See
210
+ [CONTRIBUTING.md](https://github.com/elinscott/pydantic-espresso/blob/master/.github/CONTRIBUTING.md)
211
+ for more information on getting involved.
212
+
213
+ ## 👋 Attribution
214
+
215
+ ### ⚖️ License
216
+
217
+ The code in this package is licensed under the MIT License.
218
+
219
+ <!--
220
+ ### 📖 Citation
221
+
222
+ Citation goes here!
223
+ -->
224
+
225
+ <!--
226
+ ### 🎁 Support
227
+
228
+ This project has been supported by the following organizations (in alphabetical order):
229
+
230
+ - [Biopragmatics Lab](https://biopragmatics.github.io)
231
+
232
+ -->
233
+
234
+ <!--
235
+ ### 💰 Funding
236
+
237
+ This project has been supported by the following grants:
238
+
239
+ | Funding Body | Program | Grant Number |
240
+ |---------------|--------------------------------------------------------------|--------------|
241
+ | Funder | [Grant Name (GRANT-ACRONYM)](https://example.com/grant-link) | ABCXYZ |
242
+ -->
243
+
244
+ ### 🍪 Cookiecutter
245
+
246
+ This package was created with
247
+ [@audreyfeldroy](https://github.com/audreyfeldroy)'s
248
+ [cookiecutter](https://github.com/cookiecutter/cookiecutter) package using
249
+ [@cthoyt](https://github.com/cthoyt)'s
250
+ [cookiecutter-snekpack](https://github.com/cthoyt/cookiecutter-snekpack)
251
+ template.
252
+
253
+ ## 🛠️ For Developers
254
+
255
+ <details>
256
+ <summary>See developer instructions</summary>
257
+
258
+ The final section of the README is for if you want to get involved by making a
259
+ code contribution.
260
+
261
+ ### Development Installation
262
+
263
+ To install in development mode, use the following:
264
+
265
+ ```console
266
+ $ git clone git+https://github.com/elinscott/pydantic-espresso.git
267
+ $ cd pydantic-espresso
268
+ $ uv pip install -e .
269
+ ```
270
+
271
+ Alternatively, install using pip:
272
+
273
+ ```console
274
+ $ python3 -m pip install -e .
275
+ ```
276
+
277
+ ### Updating Package Boilerplate
278
+
279
+ This project uses `cruft` to keep boilerplate (i.e., configuration, contribution
280
+ guidelines, documentation configuration) up-to-date with the upstream
281
+ cookiecutter package. Install cruft with either `uv tool install cruft` or
282
+ `python3 -m pip install cruft` then run:
283
+
284
+ ```console
285
+ $ cruft update
286
+ ```
287
+
288
+ More info on Cruft's update command is available
289
+ [here](https://github.com/cruft/cruft?tab=readme-ov-file#updating-a-project).
290
+
291
+ ### 🥼 Testing
292
+
293
+ After cloning the repository and installing `tox` with
294
+ `uv tool install tox --with tox-uv` or
295
+ `python3 -m pip install tox tox-uv`, the unit tests in the `tests/` folder
296
+ can be run reproducibly with:
297
+
298
+ ```console
299
+ $ tox -e py
300
+ ```
301
+
302
+ Additionally, these tests are automatically re-run with each commit in a
303
+ [GitHub Action](https://github.com/elinscott/pydantic-espresso/actions?query=workflow%3ATests).
304
+
305
+ ### 📖 Building the Documentation
306
+
307
+ The documentation can be built locally using the following:
308
+
309
+ ```console
310
+ $ git clone git+https://github.com/elinscott/pydantic-espresso.git
311
+ $ cd pydantic-espresso
312
+ $ tox -e docs
313
+ $ open docs/build/html/index.html
314
+ ```
315
+
316
+ The documentation automatically installs the package as well as the `docs` extra
317
+ specified in the [`pyproject.toml`](pyproject.toml). `sphinx` plugins like
318
+ `texext` can be added there. Additionally, they need to be added to the
319
+ `extensions` list in [`docs/source/conf.py`](docs/source/conf.py).
320
+
321
+ The documentation can be deployed to [ReadTheDocs](https://readthedocs.io) using
322
+ [this guide](https://docs.readthedocs.io/en/stable/intro/import-guide.html). The
323
+ [`.readthedocs.yml`](.readthedocs.yml) YAML file contains all the configuration
324
+ you'll need. You can also set up continuous integration on GitHub to check not
325
+ only that Sphinx can build the documentation in an isolated environment (i.e.,
326
+ with `tox -e docs-test`) but also that
327
+ [ReadTheDocs can build it too](https://docs.readthedocs.io/en/stable/pull-requests.html).
328
+
329
+ #### Configuring ReadTheDocs
330
+
331
+ 1. Log in to ReadTheDocs with your GitHub account to install the integration at
332
+ https://readthedocs.org/accounts/login/?next=/dashboard/
333
+ 2. Import your project by navigating to https://readthedocs.org/dashboard/import
334
+ then clicking the plus icon next to your repository
335
+ 3. You can rename the repository on the next screen using a more stylized name
336
+ (i.e., with spaces and capital letters)
337
+ 4. Click next, and you're good to go!
338
+
339
+ ### 📦 Making a Release
340
+
341
+ #### Configuring Zenodo
342
+
343
+ [Zenodo](https://zenodo.org) is a long-term archival system that assigns a DOI
344
+ to each release of your package.
345
+
346
+ 1. Log in to Zenodo via GitHub with this link:
347
+ https://zenodo.org/oauth/login/github/?next=%2F. This brings you to a page
348
+ that lists all of your organizations and asks you to approve installing the
349
+ Zenodo app on GitHub. Click "grant" next to any organizations you want to
350
+ enable the integration for, then click the big green "approve" button. This
351
+ step only needs to be done once.
352
+ 2. Navigate to https://zenodo.org/account/settings/github/, which lists all of
353
+ your GitHub repositories (both in your username and any organizations you
354
+ enabled). Click the on/off toggle for any relevant repositories. When you
355
+ make a new repository, you'll have to come back to this
356
+
357
+ After these steps, you're ready to go! After you make "release" on GitHub (steps
358
+ for this are below), you can navigate to
359
+ https://zenodo.org/account/settings/github/repository/elinscott/pydantic-espresso
360
+ to see the DOI for the release and link to the Zenodo record for it.
361
+
362
+ #### Registering with the Python Package Index (PyPI)
363
+
364
+ You only have to do the following steps once.
365
+
366
+ 1. Register for an account on the
367
+ [Python Package Index (PyPI)](https://pypi.org/account/register)
368
+ 2. Navigate to https://pypi.org/manage/account and make sure you have verified
369
+ your email address. A verification email might not have been sent by default,
370
+ so you might have to click the "options" dropdown next to your address to get
371
+ to the "re-send verification email" button
372
+ 3. 2-Factor authentication is required for PyPI since the end of 2023 (see this
373
+ [blog post from PyPI](https://blog.pypi.org/posts/2023-05-25-securing-pypi-with-2fa/)).
374
+ This means you have to first issue account recovery codes, then set up
375
+ 2-factor authentication
376
+ 4. Issue an API token from https://pypi.org/manage/account/token
377
+
378
+ #### Configuring your machine's connection to PyPI
379
+
380
+ You have to do the following steps once per machine.
381
+
382
+ ```console
383
+ $ uv tool install keyring
384
+ $ keyring set https://upload.pypi.org/legacy/ __token__
385
+ $ keyring set https://test.pypi.org/legacy/ __token__
386
+ ```
387
+
388
+ Note that this deprecates previous workflows using `.pypirc`.
389
+
390
+ #### Uploading to PyPI
391
+
392
+ After installing the package in development mode and installing
393
+ `tox` with `uv tool install tox --with tox-uv` or
394
+ `python3 -m pip install tox tox-uv`, run the following from the console:
395
+
396
+ ```console
397
+ $ tox -e finish
398
+ ```
399
+
400
+ This script does the following:
401
+
402
+ 1. Uses [bump-my-version](https://github.com/callowayproject/bump-my-version) to
403
+ switch the version number in the `pyproject.toml`, `CITATION.cff`,
404
+ `src/pydantic_espresso/version.py`, and
405
+ [`docs/source/conf.py`](docs/source/conf.py) to not have the `-dev` suffix
406
+ 2. Packages the code in both a tar archive and a wheel using
407
+ [`uv build`](https://docs.astral.sh/uv/guides/publish/#building-your-package)
408
+ 3. Uploads to PyPI using
409
+ [`uv publish`](https://docs.astral.sh/uv/guides/publish/#publishing-your-package).
410
+ 4. Push to GitHub. You'll need to make a release going with the commit where the
411
+ version was bumped.
412
+ 5. Bump the version to the next patch. If you made big changes and want to bump
413
+ the version by minor, you can use `tox -e bumpversion -- minor` after.
414
+
415
+ #### Releasing on GitHub
416
+
417
+ 1. Navigate to
418
+ https://github.com/elinscott/pydantic-espresso/releases/new
419
+ to draft a new release
420
+ 2. Click the "Choose a Tag" dropdown and select the tag corresponding to the
421
+ release you just made
422
+ 3. Click the "Generate Release Notes" button to get a quick outline of recent
423
+ changes. Modify the title and description as you see fit
424
+ 4. Click the big green "Publish Release" button
425
+
426
+ This will trigger Zenodo to assign a DOI to your release as well.
427
+
428
+ </details>