-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpyproject.toml
190 lines (159 loc) · 5.12 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "zospy"
authors = [
{ name = "Luc van Vught" },
{ name = "Jan-Willem Beenakker" },
{ name = "Corné Haasjes" },
]
description = "A Python package used to communicate with Zemax OpticStudio through the API"
readme = "README.md"
license = { file = "LICENSE.txt" }
keywords = ["Zemax", "OpticStudio", "API", "ZOSAPI"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Typing :: Typed",
]
requires-python = ">=3.9,<3.14"
dependencies = [
"lark ~= 1.2.0",
"pythonnet >=3.0.0,<4",
"pandas",
"pydantic >= 2.4.0",
"numpy",
"semver >= 3.0.0,<4",
"eval_type_backport; python_version <= '3.9'", # TODO: Remove when dropping support for Python 3.9
"typing_extensions; python_version <= '3.10'",
]
dynamic = ["version"]
[project.urls]
Source = "https://github.com/MREYE-LUMC/ZOSPy"
Documentation = "https://mreye-lumc.github.io/ZOSPy"
[project.optional-dependencies]
docs = [
"ipython",
"myst-parser",
"nbsphinx",
"numpydoc",
"sphinx",
"sphinx-book-theme",
"sphinx-design",
]
### Hatch configuration
[tool.hatch.version]
path = "zospy/__init__.py"
[tool.hatch.envs.default]
python = "3.12"
installer = "uv"
path = ".venv"
dependencies = ["pytest"]
[tool.hatch.envs.default.scripts]
test-extension = "hatch test --extension {args}"
# Build and serve documentation
docs = ["hatch run docs:build", "hatch run docs:serve"]
# Run examples using the development version of ZOSPy
example = "{env:HATCH_UV:uv} run --isolated scripts/run_examples/run_single_example.py {args} --zospy-location ."
all-examples = "{env:HATCH_UV:uv} run --isolated scripts/run_examples/run_all_examples.py {args:examples} --zospy-location ."
# Format docstrings according to numpydoc
format-docstrings = "{env:HATCH_UV:uv} tool uvx pydocstringformatter --write {args:examples scripts tests zospy}"
# Generate reference data for unit tests
generate-reference-data = "hatch run reference-data:generate"
## Unit testing using hatch test
[tool.hatch.envs.hatch-test]
randomize = false
retries = 0
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.13", "3.12", "3.11", "3.10", "3.9"]
## Documentation
[tool.hatch.envs.docs]
installer = "uv"
features = ["docs"]
[tool.hatch.envs.docs.scripts]
# Build documentation; run as hatch run docs:build
build = "sphinx-build -M {args:html} ./docs ./docs/_build"
# Serve documentation locally; run as hatch run docs:serve
serve = "python -m http.server -d ./docs/_build/html {args:8888}"
## Examples
[tool.hatch.envs.examples]
installer = "uv"
dependencies = ["jupyter", "matplotlib", "numpy", "pandas", "pip"]
## Test reference data generation
[tool.hatch.envs.reference-data]
dependencies = ["pyyaml"]
[tool.hatch.envs.reference-data.scripts]
generate = "python scripts/generate_test_reference_data {args}"
## Formatting using hatch fmt
[tool.hatch.envs.hatch-static-analysis]
config-path = "ruff_defaults.toml"
# Linting and formatting options
[tool.ruff]
extend = "ruff_defaults.toml"
line-length = 120
extend-include = ["*.ipynb"]
exclude = [
"zospy/api/_ZOSAPI",
"zospy/api/_ZOSAPI_constants",
"zospy/analyses/old",
]
[tool.ruff.lint]
extend-select = [
"D", # pydocstyle
"NPY", # numpy-specific
"RUF", # ruff-specific
]
extend-ignore = ["B028", "EM101", "EM102", "G004", "PLR2004", "TD004", "TRY003"]
[tool.ruff.lint.extend-per-file-ignores]
"examples/**" = [
"D", # pydocstyle
"FBT002", # Allow positional boolean arguments
"INP001", # Do not require __init__.py
"RET504",
"S101", # Allow use of assert
"TCH", # Do not require type checking blocks
"T201", # Allow use of print
]
"**/tests/**" = [
"D", # pydocstyle
"DTZ", # Datetime timezones
]
"scripts/**" = [
"D", # pydocstyle
"S101", # Use of assert
]
"docs/conf.py" = [
"INP001", # Missing __init__.py
"D100", # Missing docstring in public module
"D103", # Missing docstring in public function
]
[tool.ruff.lint.flake8-pytest-style]
parametrize-names-type = "csv"
[tool.ruff.lint.pydocstyle]
convention = "numpy"
[tool.pydocstringformatter]
style = "numpydoc"
max-line-length = 120
max-summary-lines = 1
summary-quotes-same-line = true
linewrap-full-docstring = true
[tool.pytest.ini_options]
markers = [
"must_pass: test must pass, otherwise all other tests will be skipped",
"old_analyses: test is part of the old analyses and will be skipped by default",
"require_mode: requires the specified connection mode, otherwise the test will be skipped",
"skip_for_opticstudio_versions: test is skipped for specific OpticStudio versions",
"xfail_for_opticstudio_versions: test is expected to fail for specific OpticStudio versions",
]
filterwarnings = [
"ignore:Header and row length mismatch",
"ignore:The `zospy.analyses.old` module contains the deprecated analysis API"
]
[tool.mypy]
files = ["zospy"]
pretty = true
[[tool.mypy.overrides]]
module = ["zospy.api._ZOSAPI", "zospy.api._ZOSAPI_constants"]
ignore_errors = "True"