-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpyproject.toml
More file actions
406 lines (361 loc) · 12.3 KB
/
Copy pathpyproject.toml
File metadata and controls
406 lines (361 loc) · 12.3 KB
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
[build-system]
requires = [
"nanobind-backend>=1.0.0",
"nanobind==3.0.0",
"scikit-build-core>=1.0.3,<2",
"setuptools-scm>=8",
]
build-backend = "scikit_build_core.build"
[project]
name = "monoprop"
authors = [
{ name = "Algorithmiq Development Team", email = "info@algorithmiq.fi" },
]
description = "Quantum circuit simulation with monomial propagation. Both Pauli and Majorana supported."
license = "Apache-2.0"
license-files = ["LICENSE"]
readme = "README.md"
requires-python = ">=3.11,<3.15"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = ["msgpack>=1.0.0", "nanobind-backend>=1.0.0", "numpy>=2"]
[project.urls]
Homepage = "https://github.com/Algorithmiq/monoprop"
"Bug Tracker" = "https://github.com/Algorithmiq/monoprop/issues"
Discussions = "https://github.com/Algorithmiq/monoprop/discussions"
Changelog = "https://github.com/Algorithmiq/monoprop/releases"
[project.optional-dependencies]
mpi = ["mpi4py>=4.1.0"]
qiskit = ["qiskit>=2.0.0"]
[dependency-groups]
dev = ["prek>=0.4", "ruff==0.15.20"]
# The documentation site is built with Fumadocs (Next.js); see `docs/`.
# Python's only roles are converting the tutorial notebooks to Markdown
# (`nbconvert`) and dumping the API surface from docstrings (`griffe`, driven by
# `docs/scripts/gen_api_dump.py` in the `gen-api` recipe).
docs = [
"griffelib>=2.2,<3",
"nbconvert",
"pytest-markdown-docs",
{ include-group = "interactive" },
]
interactive = [
"ipykernel",
"matplotlib",
"pylatexenc",
"qiskit>=2.0.0",
"pyscf",
]
# Dependencies of monoprop's own suite (`tests/`). Deliberately free of workspace
# members: cibuildwheel installs this group to exercise a *built wheel*, and a
# workspace member would drag monoprop back in from source.
test = [
"psutil>=7.2",
"pytest-cases>=3.8.6,<4",
"pytest-cov>=7.1.0",
"pytest-datadir",
# depend on branch which only outputs from rank zero
"pytest-mpi @ git+https://github.com/aragilar/pytest-mpi.git@nonzero",
"pytest>=8.2.2,<9.1",
"tabulate>=0.9",
]
# What `uv run pytest` needs at the repository root, which also collects the
# workspace members' suites (see `testpaths`).
workspace-test = [{ include-group = "test" }, "monoprop-bench-tools"]
bench = [{ include-group = "workspace-test" }, "pytest-benchmark>=5"]
[tool.uv]
python-preference = "only-managed"
keyring-provider = "subprocess"
cache-keys = [
{ file = "pyproject.toml" },
{ file = "CMakeLists.txt" },
{ file = "cmake/**/*" },
{ file = "cpp/**/CMakeLists.txt" },
{ file = "cpp/include/**/*.h" },
{ file = "cpp/include/**/*.h.in" },
{ file = "cpp/monoprop/**/*.{h,cpp}" },
{ file = "src/monoprop/**/CMakeLists.txt" },
{ file = "src/monoprop/bindings/binder.h" },
{ file = "src/monoprop/bindings/bindings.cpp.in" },
{ file = "tools/*.py" },
]
[tool.uv.workspace]
members = ["packages/*"]
exclude = ["packages/bench-third-party"]
[tool.uv.sources]
monoprop-bench-tools = { workspace = true }
[[tool.dynamic-metadata]]
provider = "scikit_build_core.metadata.setuptools_scm"
[tool.scikit-build]
# protect the configuration against future changes in scikit-build-core
minimum-version = "build-system.requires"
# setuptools-style build caching in a local directory
build-dir = "build/{state}/{build_type}"
# build stable ABI wheels for CPython 3.11
wheel.py-api = "cp311"
logging.level = "INFO"
# read CMake version from CMakeLists.txt
cmake.version = "CMakeLists.txt"
cmake.build-type = "Release"
ninja.make-fallback = false
sdist.exclude = [
".github",
".devcontainer",
".vscode",
"packages",
"performance_scripts",
"results",
"src/ex_script.cpp",
"tests/cpp",
"sandbox",
".clang-format",
".clang-tidy",
".copier-answers.yml",
".gersemirc",
".gitignore",
"flake.lock",
"flake.nix",
"nix",
"prek.toml",
".prettierignore",
"cspell.json",
]
sdist.include = [
"src/monoprop/_version.py",
"src/monoprop/_dispatch.py",
".github/license-header.txt",
]
build.verbose = true
build.tool-args = ["-j2"]
# monoprop_ENABLE_MPI is the source-build switch. Overrides can only match
# environment variables, never config-settings, so setting an equivalent CMake
# define directly does not activate any associated build requirements.
[[tool.scikit-build.overrides]]
if.env.monoprop_ENABLE_MPI = true
build.requires = ["mpi4py>=4.1.0"]
cmake.define.monoprop_ENABLE_MPI = "ON"
[tool.setuptools_scm]
write_to = "src/monoprop/_version.py"
[tool.pytest.ini_options]
minversion = "8.0"
log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s (%(filename)s:%(lineno)s)"
log_date_format = "%Y%m%d %H:%M:%S"
addopts = [
"--import-mode=importlib",
"-ra",
"--showlocals",
"--strict-markers",
"--strict-config",
]
xfail_strict = true
filterwarnings = ["error"]
testpaths = ["tests", "packages/monoprop-bench-tools/tests"]
# Collect both the test suite (test_*.py) and the benchmark suite (bench_*.py);
# benches/ is excluded from testpaths so it only runs when invoked explicitly.
python_files = ["test_*.py", "bench_*.py"]
pythonpath = ["."]
markers = [
"slow: mark test as slow (>=1 minute runtime)",
"mpi: mark test as requiring --with-mpi (pytest-mpi)",
"qiskit: mark test as requiring qiskit (optional dependency)",
]
required_plugins = ["pytest-cases", "pytest-datadir", "pytest-mpi"]
[tool.coverage.run]
source = ["src/monoprop"]
branch = true
relative_files = true
omit = ["src/monoprop/_version.py", "src/monoprop/_dispatch.py"]
[tool.coverage.report]
omit = ["src/monoprop/_version.py", "src/monoprop/_dispatch.py"]
exclude_also = [
'\.\.\.',
"def __repr__",
"if self.debug:",
"if settings.DEBUG:",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
"if (typing\\.)?TYPE_CHECKING:",
"@jit\\(",
"@njit\\(",
'^\s*\.\.\.',
"logger =",
"logger\\.",
"return NotImplemented",
"@overload",
]
[tool.ruff]
# for the default settings, see: https://docs.astral.sh/ruff/configuration/#configuring-ruff
exclude = [
"src/monoprop/_version.py",
"packages/monoprop-bench-tools/src/monoprop_bench_tools/_version.py",
"docs/conf.py",
"performance_scripts/*.py",
]
target-version = "py311"
[tool.ruff.format]
# enable auto-formatting of code examples in docstrings
docstring-code-format = true
# set the line length limit used when formatting code snippets in
# docstrings
docstring-code-line-length = "dynamic"
[tool.ruff.lint]
extend-select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # mccabe
"D", # pydocstyle
"E",
"W", # pycodestyle
"ERA", # eradicate
"EXE", # flake8-executable
"FBT", # flake8-boolean-trap
"FLY", # flynt
"FURB", # refurb
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"ISC003", # flake8-implicit-str-concat: explicit-string-concatenation (other rules conflict with the formatter)
"N", # pep8-naming
"NPY", # NumPy-specific rules
"PERF", # perflint
"PIE", # flake8-pie
"PLC", # pylint convention
"PLE", # pylint error
"PLR", # pylint refactor
"PLW", # pylint warning
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slot
"T20", # flake8-print
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"YTT", # flake8-2020
"TRY", # tryceratops
]
ignore = [
"D206", # indent-with-spaces: enforced by the formatter
"E111", # indentation-with-invalid-multiple: enforced by the formatter
"E114", # indentation-with-invalid-multiple-ment: enforced by the formatter
"E117", # over-indented: enforced by the formatter
"N803", # pep8-naming: "argument name should be lowercase"
"N806", # pep8-naming: "variable in function should be lowercase"
"PLR0913", # pylint refactor: "too many arguments to function call"
"PLR0915", # pylint refactor: "too many statements"
"PLR2004", # pylint refactor: "magic value used in comparison"
"TRY003", # tryceratops: "Avoid specifying long messages outside the exception class"
"W191", # tab-indentation: enforced by the formatter
]
# do not attempt autofix with `--fix` for the following rules
unfixable = [
"ERA", # removes commented-out code
"F401", # removes unused imports
"F841", # removes unused variables
"T20", # removes print statements
]
# allow unused variadic arguments, like *args and **kwargs.
flake8-unused-arguments.ignore-variadic-names = true
flake8-annotations.allow-star-arg-any = true
[tool.ruff.lint.per-file-ignores]
# ignore for contents of `tests`:
# - S101 (flake8-bandit `AssertUsed`),
# - D (pydocstyle)
# - C901 (mccabe)
# - INP001 (flake8-no-pep420)
# - E721 (type-comparison)
"tests/*" = ["S101", "D", "C901", "INP001", "E721"]
# ignore for all `test_*.py` files
# - ANN (flake8-annotations)
# - I002 (isort required import)
"tests/**/test_*.py" = ["ANN", "I002"]
# workspace members carry their own test suites, under the same relaxations
"packages/*/tests/*" = ["S101", "D", "C901", "INP001", "E721", "ANN", "I002"]
# ignore I002 (isort required import) for all `__init__.py` files
"src/monoprop/**/__init__.py" = ["I002"]
# benchmark suite: asserts are fine (S101), it is an intentional non-package
# directory holding pytest modules (INP001), and the MPI communicator type is
# unavoidably dynamic (ANN401).
"benches/*" = ["S101", "INP001", "ANN401"]
# benchmark test functions: annotations on the pytest signatures are just noise.
"benches/bench_*.py" = ["ANN"]
# the report renderer writes to stdout by design (T201) and the MPI communicator
# type is unavoidably dynamic (ANN401).
"packages/monoprop-bench-tools/src/**" = ["ANN401", "T201"]
# cupy comes from an optional, GPU-only extra, so it is imported inside the
# functions that need it (PLC0415).
"packages/monoprop-bench-tools/src/monoprop_bench_tools/memory/gpu.py" = [
"PLC0415",
]
[tool.ruff.lint.pycodestyle]
# maximum line length to allow for line-length violations within documentation,
# including standalone comments
max-doc-length = 140
max-line-length = 120
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
[tool.pyright]
pythonVersion = "3.11"
include = ["src/monoprop/**/*.py"]
exclude = ["test_*.py", "docs/**", "**/__pycache__"]
typeCheckingMode = "basic"
useLibraryCodeForTypes = true
reportGeneralTypeIssues = "information"
reportMissingImports = true
reportMissingTypeStubs = "warning"
reportImportCycles = "information"
reportPrivateUsage = "information"
reportPrivateImportUsage = "information"
reportUnnecessaryIsInstance = "information"
reportUnnecessaryCast = "information"
reportUnnecessaryComparison = "information"
reportUnnecessaryContains = "information"
reportUnnecessaryTypeIgnoreComment = "information"
reportMatchNotExhaustive = "information"
[tool.cibuildwheel]
build = "cp3??-*"
build-frontend = "uv"
build-verbosity = 1
skip = ["*-musllinux_*"]
test-command = "python -m pytest {package}/tests"
test-groups = ["test"]
test-extras = ["qiskit"]
[tool.cibuildwheel.linux]
before-all = ["./tools/install-deps.sh --skip-boost-test --skip-msgpack"]
environment = { SKBUILD_CMAKE_ARGS = "-Dmonoprop_ENABLE_ARCH_FLAGS=OFF;-Dmonoprop_ENABLE_CXX_UNIT_TESTS=OFF;-Dmonoprop_ENABLE_MPI=OFF" }
[tool.cibuildwheel.macos]
before-all = "brew install boost hwloc"
environment = { MACOSX_DEPLOYMENT_TARGET = "15.0", SKBUILD_CMAKE_ARGS = "-Dmonoprop_ENABLE_ARCH_FLAGS=OFF;-Dmonoprop_ENABLE_CXX_UNIT_TESTS=OFF;-Dmonoprop_ENABLE_MPI=OFF" }