-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
332 lines (298 loc) · 8.66 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
[build-system]
# See https://pypi.org/project/hatchling/
requires = ["hatchling", "hatch-vcs>=0.3"]
build-backend = "hatchling.build"
[project]
name = "pharaoh-report"
dynamic = ["version"]
description = """Pharaoh is a Sphinx-based Python framework
for generating reports in various formats by combining the
power of configurable Jinja templates and Python scripts
for asset generation."""
readme.content-type = "text/markdown"
readme.file = "README.md"
authors = [{ name = "Johannes Loibl", email = "" }]
license = { text = "MIT" }
keywords = [
"reporting",
"sphinx",
"jinja",
"templating",
]
requires-python = ">=3.9.2"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
]
urls.Documentation = "https://infineon.github.io/pharaoh-dev/"
urls.Homepage = "https://infineon.github.io/pharaoh-dev/"
urls."Release Notes" = "https://infineon.github.io/pharaoh-dev/changelog.html"
urls.Source = "https://github.com/Infineon/pharaoh-dev"
urls.Tracker = "https://github.com/Infineon/pharaoh-dev/issues"
dependencies = [
"attrs",
"click", # CLI
"omegaconf", # yaml R/W
"natsort", # sorting paths naturally
"pyyaml!=5.3.0",
"pluggy",
"nbconvert", # used to programmatically execute asset notebooks
"mistletoe", # Markdown to HTML
# Sphinx, theme & extensions
"sphinx >=7.2.5, <8.0",
"sphinxcontrib-jquery",
"sphinx-design",
"sphinx-rtd-theme<3.0",
# "sphinx-toolbox",
# "sphinx-data-viewer",
# Jinja & extensions
"jinja2",
"jinja2-git",
"jinja2-ansible-filters",
"wrapt",
]
[project.optional-dependencies]
bokeh = [
"bokeh>=3.0.0,<3.3.0; python_version>='3.9'",
"bokeh>=3.1.0,<3.3.0; python_version>='3.11'",
"selenium>=4.11",
]
holoviews = [
"holoviews",
"holoviews>=1.16; python_version>='3.11'",
]
matplotlib = ["matplotlib"]
plotly = [
"plotly",
# Newer kaleido versions leads to deadlocks, see https://github.com/plotly/Kaleido/issues/110"
"kaleido==0.1.0.post1; platform_system=='Windows'",
"kaleido<0.4; platform_system=='Linux'",
]
jupyter = [
"jupyter",
"jupyter_contrib_nbextensions",
]
pandas = [
"pandas>=1.5", # reset_index(names=...)
]
pdf = [
"sphinxcontrib-svg2pdfconverter", # https://pypi.org/project/sphinxcontrib-svg2pdfconverter/
]
all-plotting = [
"pharaoh-report[pandas,bokeh,holoviews,matplotlib,plotly,jupyter]",
]
docs = [
"sphinx<8",
"sphinx-rtd-theme",
"sphinx-design",
"sphinxcontrib-jquery",
"sphinx-jinja",
"sphinx-copybutton",
]
dev = [
"pytest",
"pytest-sugar",
"pytest-cov",
"pytest-mock",
"pytest-timeout",
"pytest-xdist",
"pytest-randomly",
"mypy",
"pharaoh-report[all-plotting,docs]",
]
[project.scripts]
pharaoh = "pharaoh.cli:cli"
[tool.hatch]
build.dev-mode-dirs = ["src"]
build.targets.sdist.packages = ["src"]
build.targets.wheel.packages = ["src/pharaoh"]
build.hooks.vcs.version-file = "src/pharaoh/version.py"
version.source = "vcs"
# https://hatch.pypa.io/latest/config/environment/overview/
[tool.hatch.envs.default]
installer = "uv"
python = "3.11" # Specifies the Python version for the default development environment
features = ["dev"]
[tool.hatch.envs.default.env-vars]
[tool.hatch.envs.default.scripts]
# Runs all tests
test = [
"""python -c "from pathlib import Path;Path('.tmp').mkdir(parents=True, exist_ok=True)" """,
"pytest --basetemp=.tmp/pytest --timeout=120 -n={env:PYTEST_XDIST_AUTO_NUM_WORKERS:auto} {args}",
]
# Runs all tests including coverage and junit xml output
cov = [
"""python -c "from pathlib import Path;Path('.tmp').mkdir(parents=True, exist_ok=True)" """,
"""pytest \
--basetemp=.tmp/pytest \
{args: \
--junitxml .tmp/junit.{env_name}.xml \
--cov \
--cov-context test \
--cov-config pyproject.toml \
--cov-report term-missing:skip-covered \
--cov-report html:.tmp/htmlcov \
--cov-report xml:.tmp/coverage.{env_name}.xml \
--no-cov-on-fail \
--timeout=120 \
-n={env:PYTEST_XDIST_AUTO_NUM_WORKERS:auto} \
}""",
]
# Installs the current package in editable mode.
# This script may be used to quickly install missing entry points or dependencies
# that are not tracked by Hatch.
dev = [
"hatch build",
"{env:HATCH_UV} pip install -e .",
]
# Cleans files that are ignored by Git
clean = [
"git clean -ffX .tmp", # Temporary files from testing
"git clean -fX .coverage*",
"git clean -fX dist", # Built documentation and distributions (wheels etc)
"git clean -fX src/*/version.py",
]
# Builds documentation with upcoming changelog and runs link checks
docs = [
"hatch build",
"python docs/cli/generate_cli_command_docs.py",
"sphinx-build -E -W -b html docs dist/docs",
"- sphinx-build -b linkcheck docs dist/docs",
]
# Runs mypy
type = "hatch run ci:mypy --install-types --non-interactive src {args}"
# Runs ruff without auto-fixes
style = "ruff check {args:.}"
# Runs pre-commit (includes ruff with auto-fixes and other stuff) on all files
fix = [
"pre-commit install",
"pre-commit run {args:--all-files}",
]
[tool.hatch.envs.all]
dev-mode = false # for matrix tests we want the packages to be installed non-editable
# https://hatch.pypa.io/latest/config/environment/advanced/#matrix
[[tool.hatch.envs.all.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]
# An environment for CI only to speed up env creation for certain jobs
[tool.hatch.envs.ci]
skip-install = true
########
# Ruff #
########
[tool.ruff]
# https://docs.astral.sh/ruff/settings
target-version = "py39"
line-length = 120
fix = false # Allow autofix for all enabled rules (when `--fix`) is provided.
show-fixes = true
unsafe-fixes = true
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"B", # bugbear
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"EM", # flake8-errmsg
"FA", # flake8-future-annotations
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TID252", # flake8-tidy-imports -> convert relative-imports (makes absolufiy-imports hook redundant)
"TCH", # flake8-type-checking
"PLE", # Pylint - errors
"PLW", # Pylint - warnings
"PLC", # Pylint - conventions
"RUF", # Ruff-specific rules
]
ignore = [
"PLW2901", # Pylint - warnings: redefined-loop-name
"E501", # https://docs.astral.sh/ruff/faq/#is-the-ruff-linter-compatible-with-black
]
exclude = [
"tests/templates/*"
]
[tool.ruff.lint.isort]
known-first-party = ["pharaoh", "test"]
required-imports = ["from __future__ import annotations"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"api.py" = ["F401"]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"
############
# Coverage #
############
# https://coverage.readthedocs.io/en/latest/config.html#
[tool.coverage.run]
source_pkgs = ["pharaoh"]
branch = true
parallel = true
relative_files = true
[tool.coverage.paths]
ifx_pharaoh = ["src/pharaoh", "*site-packages/pharaoh"]
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"pragma: nocover",
"def __repr__",
"def __str__",
"raise AssertionError",
"no cov",
"if __name__ == \"__main__\":",
"if TYPE_CHECKING:",
]
##########
# PyTest #
##########
# https://docs.pytest.org/en/stable/reference/customize.html#pyproject-toml
[tool.pytest.ini_options]
# timeout = 30
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = "--tb=auto -ra --showlocals -vv"
testpaths = [
"tests/unit",
"tests/integration",
]
########
# MYPY #
########
# https://justincaustin.com/blog/mypy-tips-and-tricks/
[tool.mypy]
# disallow_any_generics = true
# disallow_incomplete_defs = true
# disallow_untyped_calls = true
# disallow_untyped_decorators = true
# disallow_untyped_defs = true
follow_imports = "normal"
ignore_missing_imports = true
no_implicit_reexport = true
show_error_codes = true
show_error_context = true
strict_equality = true
strict_optional = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_ignores = true
disable_error_code = [
"import-untyped",
"no-redef",
"union-attr",
"attr-defined",
]