forked from rorni/mckit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
632 lines (553 loc) · 18.9 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
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
[tool.poetry]
name = "mckit"
version = "0.8.3"
description = "Tools to process MCNP models and results"
authors = ["rrn <[email protected]>"]
maintainers = ["dpv2015 <[email protected]>"]
homepage = "https://github.com/MC-kit/mckit"
repository = "https://github.com/MC-kit/mckit"
documentation = "https://mckit.readthedocs.io"
license = "GPL3"
keywords = ["mckit", "MCNP"]
readme = "README.rst"
packages = [
{ include = "mckit", from = "src" },
{ include = "building", format = "sdist", from = "." },
{ include = "tests", format = "sdist", from = "." },
# { include = "benchmarks", format="sdist", from = "."},
]
include = [
"src/mckit/data/isotopes.dat",
{ path = "build.py", format = "sdist" },
# C extensions must be included in the wheel distribution.
{ path = "src/mckit/**/*.pyd", format = "wheel" },
{ path = "src/mckit/**/*.so", format = "wheel" },
]
exclude = [
".py[co]$",
"setup.py"
]
# Select from PyPI classifiers: https://pypi.org/classifiers/
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: C",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Physics",
]
[build-system]
requires = [
"poetry-core >= 1.8.3",
"cmake >= 3.26.3",
"ninja; platform_system!='Windows'",
"setuptools >= 67.8.0",
"numpy >= 1.26.0",
"mkl-devel >= 2024.2.0",
"intel-openmp >= 2024.2.0",
"tbb >= 2021.13.0",
"scikit-build"
]
build-backend = "poetry.core.masonry.api"
[tool.poetry.build]
script = "build.py"
generate-setup-file = true
#[tool.skikit-build]
#cmake.verbose = true
[tool.poetry.scripts]
mckit = "mckit.cli.runner:mckit"
[tool.poetry.urls]
"Repository" = "https://github.com/MC-kit/mckit"
"Bug Tracker" = "https://github.com/MC-kit/mckit/issues"
# "Documentation" TODO
[tool.poetry.dependencies]
python = ">=3.10,<3.14"
DateTime = ">=4.3"
attrs = ">=21.2.0"
click = ">=8.0.1"
colorama = ">=0.4.4"
loguru = ">=0.6.0"
numpy = ">=1.26.0"
ply = ">=3.11"
python-dotenv = ">=0.20.0"
scipy = ">=1.14.0"
sly = ">=0.4"
tomli = { version = ">=2.0.1", python = "<3.11" }
tomli-w = ">=1.0.0"
tqdm = ">=4.55.1"
# the last mkl version with wheels for Linux, Windows and MacOS, check on updates
# the most recent version was 2024.0.0 (windows and linux only).
# Same for intel-openmp and tbb.
mkl-devel = ">=2024.2.0"
intel-openmp = ">=2024.2.0"
tbb = ">=2021.13.0"
# The following works for linux and windows, but not for macos
# besides we need to have the same versions on build (see [build-system]),
# so, we use the most recent version compatbile to all the OS.
#mkl-devel = [
# {version = "2023.0.0", markers = "sys_platform == 'linux'"},
# {version = "2023.0.0", markers = "sys_platform == 'darvin'"},
# {version = "2022.2.1", markers = "sys_platform == 'win32'"}
#]
#intel-openmp = [
# {version = "2023.0.0", markers = "sys_platform == 'linux'"},
# {version = "2023.0.0", markers = "sys_platform == 'darvin'"},
# {version = "2022.2.1", markers = "sys_platform == 'win32'"}
#]
#tbb = [
# {version = "2021.8.0", markers = "sys_platform == 'linux'"},
# {version = "2021.8.0", markers = "sys_platform == 'darvin'"},
# {version = "2021.7.1", markers = "sys_platform == 'win32'"}
#]
# Check MKL wheels availablility:
# https://pypi.org/simple/mkl-devel/
# https://pypi.org/simple/intel-openmp/
# https://pypi.org/simple/tbb/
# Also interesting: https://pypistats.org/packages/mkl - no visible MacOS downloads
# As for 2022.01.12 for MacOS only version 10.15 is supported
# TODO dvp: automate the check above
#
# TODO dvp: check
# https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl/link-line-advisor.html
#
typer = { extras = ["all"], version = ">=0.9.0" }
[tool.poetry.group.dev.dependencies]
Pygments = ">=2.10.0"
nox = ">=2022.1.7"
scikit-build = ">=0.17.6"
[tool.poetry.group.pre_commit.dependencies]
pre-commit = ">=2.15.0"
rstcheck = ">=6.1.2"
pydocstringformatter = ">=0.7.3"
pyupgrade = ">=3.15.0"
[tool.poetry.group.test.dependencies]
pytest = ">=7.1"
pytest-benchmark = ">=4.0.0"
# pytest-cache = ">=1.0"
pytest-cov = ">=4.0"
# pytest-mock = ">=3.9"
# pytest-randomly = ">=3.12"
coverage = { version = ">=6.1.2", extras = ["toml"] }
xdoctest = { extras = ["colors"], version = ">=0.15.10" }
[tool.poetry.group.coverage.dependencies]
coverage = { version = ">=6.1.2", extras = ["toml"] }
[tool.poetry.group.xdoctest.dependencies]
xdoctest = { extras = ["colors"], version = ">=0.15.10" }
[tool.poetry.group.typeguard.dependencies]
typeguard = ">=4.1.5"
[tool.poetry.group.mypy.dependencies]
mypy = ">=1.2.0"
pep8-naming = ">=0.12.1"
types-setuptools = ">=57.4.2"
numpy = ">=1.26.2"
types-tqdm = ">=4.66.0.2"
[tool.poetry.group.docs.dependencies]
sphinx = ">=6.1.3"
sphinx-autodoc-typehints = ">=1.19.5"
sphinx-click = ">=4.4.0"
[tool.poetry.group.docs_auto.dependencies]
sphinx-autobuild = ">=2021.3.14"
[tool.poetry.group.ruff.dependencies]
ruff = ">=0.0.259"
[tool.poetry.group.analyze.dependencies]
jupyterlab = "^4.2.5"
jupytext = "^1.16.4"
[tool.pytest.ini_options]
minversion = "6.2"
cache_dir = '.cache/pytest'
norecursedirs = '''
*.egg-info
.*
build
data
dist
docs/_build
docs/examples
htmlcov
notebooks
tools
wrk
'''
python_functions = "test_* profile_*"
addopts = '''
-ra
-q
--tb=short
--doctest-modules
--strict-markers
--ignore setup.py
--failed-first
--xdoctest
--benchmark-disable
--benchmark-storage=.cache/benchmarks
--benchmark-autosave
--benchmark-compare
--benchmark-group-by=name,fullname
'''
doctest_optionflags = "ELLIPSIS NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ALLOW_UNICODE ALLOW_BYTES"
testpaths = ["tests", "src"]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]
# xfail tests that pass should fail the test suite
xfail_strict = true
filterwarnings = [
"error",
'ignore:Implementing implicit namespace packages \(as specified in PEP 420\) is preferred to `pkg_resources.declare_namespace`',
"ignore:.*not typechecking multipledispatch.dispatcher.*UserWarning",
'ignore:.*io.FileIO \[closed\]',
'ignore:.*Deprecated call to `pkg_resources.declare_namespace',
'ignore:.*Implicit None on return values:DeprecationWarning',
# pandas 2.1.4 at python 3.12
'ignore:.*datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning',
# openpyxl 3.1.2 qt python 3.12
'ignore:.*datetime.datetime.utcnow\(\):DeprecationWarning'
]
log_format = "%(asctime)s %(levelname)s %(message)s"
log_date_format = "%Y-%m-%d %H:%M:%S"
[tool.xdoctest]
quiet = true
options = ""
[tool.coverage.paths]
source = ["src", ".nox/*/site-packages"]
[tool.coverage.run]
branch = true
source = ["src"]
omit = ["*_tab.py", "**/__init__.py"]
[tool.coverage.report]
show_missing = true
skip_covered = true
fail_under = 90 # TODO dvp: increase limit to 100 with code maturing
omit = ["*_tab.py", "**/__init__.py"]
# Regexes for lines to exclude from consideration
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about missing debug-only code:
"def __repr__",
"if self.debug",
# Don't complain if tests don't hit defensive assertion code:
"raise AssertionError",
"raise NotImplementedError",
# Don't complain if non-runnable code isn't run:
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
ignore_errors = true
sort = "Cover"
# MyPy config
# See https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
# https://dev.to/tusharsadhwani/the-comprehensive-guide-to-mypy-561m
[tool.mypy]
python_version = "3.12"
# strict = true # TODO dvp: uncomment this to get strict control
follow_imports = "silent"
# namespace_packages = true
warn_return_any = true
warn_unused_configs = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
disable_error_code = ["annotation-unchecked"]
show_error_context = true
error_summary = true
warn_redundant_casts = true
warn_unreachable = true
warn_unused_ignores = true
files = "src/**/*.py"
exclude = '''
(?x)(
parser\.py$ # mypy doesn't parser code
| _tab\.py$ # ...
| lexer\.py$ # ...
)
'''
plugins = ["numpy.typing.mypy_plugin"]
[[tool.mypy.overrides]]
module = [
"IPython.core.magic",
"IPython.core.magic_arguments",
"click",
"click.testing",
"loguru",
"mckit.*", # TODO (dvp, style): make everything typed including extension 'geometry'
"multipledispatch",
"nox",
"numpy.testing",
"pandas",
"pytest",
"scipy.constants",
"scipy.sparse",
"tomli",
"tomllib",
"xdoctest",
]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = [
"tomllib",
"tomli",
]
allow_redefinition = true
disable_error_code = "no-redef"
[tool.check-manifest]
ignore = [
"tests/*",
"tools/*",
"*.yaml",
"noxfile.py",
]
[tool.ipdb]
# For debugging in jupyterlab and ipython
# see https://github.com/gotcha/ipdb
context = 5
[tool.tryceratops]
include = ["src"]
experimental = true
[tool.pydocstringformatter]
write = true
style = "pep257"
exclude = ["tools/**", "src/**/*_parser.py", "src/**/*_tab.py"]
strip-whitespaces = true
max-line-length = 100
summary-quotes-same-line = true
[tool.pylint]
good-names-rgxs = ["."] # a single character variable is okay
logging-format-style = "new" # use {} in logging messages
deprecated-modules = ["six"]
extension-pkg-allow-list = ["duckdb"]
disable = [
"wrong-import-order" # this is `ruff format` responsibility
]
[tool.ruff]
target-version = "py310"
line-length = 100
# show an enumeration of all autofixed lint violations
show-fixes = true
# show source code snippets when reporting violations
output-format = "concise"
src = ["src", "tests"]
exclude = [
"*.egg-info",
".cache",
"__pycache__",
"adhoc",
"docs/source/conf.py",
"notebooks",
"wrk",
]
[tool.ruff.lint]
#see full list: https://beta.ruff.rs/docs/rules/#pyflakes-f
#or run 'ruff linter' to see a brief list
select = [
"A", # flake8-builtins
# "ANN", # flake8-annotations
"AIR", # Airflow https://airflow.apache.org/docs/apache-airflow/stable/index.html
# "ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # mccabe
"COM", # flake8-commas
"D", # pydocstyle
"DJ", # flake8-django
# "DTZ", # flake8-datetimez
"E", # pycodestyle
# "EM", # flake8-errmsg
# "ERA", # eradicate
# "EXE", # flake8-executable
"F", # Pyflakes
"FA", # flake8-future-annotations
# "FBT", # flake8-boolean-trap https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap
# "FIX", # flake8-fixme
"FLY", # flynt
"FURB", # refurb
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-log
"N", # pep8-naming
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
# "RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
# "SIM", # flake8-simplify
# "SLF", # flake8-self
"SLOT", # flake8-slot
"T10", # flake8-debugger
# "T20", # flake8-print
# "TD", # flake8-todos
# "TCH", # flake8-type-checking
# "TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle 2
"YTT", # flake8-2020
]
#warning: The isort option `isort.split-on-trailing-comma` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.split-on-trailing-comma=false` or `format.skip-magic-trailing-comma=false`.
# Ignore rules that currently fail on the codebase
ignore = [
"ANN001", # ANN001 Missing type annotation for function argument: doesn't allow to use functools dispatching
"ANN002", # ANN002 Missing type annotation for *drop_items: ... as above
"ANN101", # ANN101 Missing type annotation for self in method
"ANN102", # ANN102 Missing type annotation for cls in classmethod
# "ANN201", # Missing return type annotation for public function `mesh2com`
"ANN202", # ANN202 Missing return type annotation for protected function: ... dispatching
"ANN204", # ANN204 Missing return type annotation for special method
"ARG001", # Unused function argument: `expected`
# "B905", # B905 `zip()` without an explicit `strict=` parameter - ignore while support 3.9
# "C812", # C812 Missing trailing comma: black compatibility
"C901", # too complex - ...
"COM812", # [*] Trailing comma missing
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D105", # D105 Missing docstring in magic method (__hash__, __eq__)
"D104", # Missing docstring in public package
"D106", # Missing docstring in public nested class
"D107", # Missing docstring in __init__
# "D417", # Missing argument descriptions in the docstring: `config`, `ebins`, - TODO
# "E203", # E203: Whitespace before ‘:'
# "E401", # Multiple imports on one line
"E402", # Module level import not at top of file
"E501", # Line too long (<LENGTH> > 100 characters)
# "E701", # Multiple statements on one line (colon)
# "E702", # Multiple statements on one line (semicolon)
# "E703", # Statement ends with an unnecessary semicolon
# "E704", # Multiple statements on one line (def)
# "E711", # Comparison to `None` should be `cond is not None`
# "E712", # Comparison to `<BOOL>` should be `cond is <BOOL>`
# "E713", # Test for membership should be `not in`
# "E714", # Test for object identity should be `is not`
# "E721", # Do not compare types, use `isinstance()`
# "E722", # Do not use bare `except`
# "E731", # Do not assign a `lambda` expression, use a `def`
# "E741", # Ambiguous variable name: `<VARIABLE>`
# "E743", # Ambiguous function name: `<FUNCTION>`
# "EM101", # Exception must not use a string literal, assign to variable first
# "EM102", # Exception must not use an f-string literal, assign to variable first
"N803", # Argument name `R` should be lowercase
"N806", # Variable `D` in function should be lowercase
# "F401", # `<TYPE>` imported but unused
# "F403", # `from <MODULE> import *` used; unable to detect undefined names
# "F405", # `<TYPE>` may be undefined, or defined from star imports: `<MODULE>`
# "F523", # `.format` call has unused arguments at position(s): <INDEX>
# "F601", # Dictionary key literal `'<KEY>'` repeated
# "F811", # Redefinition of unused `<VARIABLE>` from line <LINE>
# "F821", # Undefined name `VARIABLE`
# "F823", # Local variable `VARIABLE` referenced before assignment
# "F841", # Local variable `VARIABLE` is assigned to but never used
# "FBT001", # Boolean positional arg in function definition (TODO!)
# "FBT002", # Boolean default value in function definition (TODO!)
# "FBT003", # Boolean positional value in function call
# "I001",
# "I101",
# "I201",
# "I202",
"INP001", # File `tools/clear-prev-dist-info.py` is part of an implicit namespace package.
"ISC001", # to avoid conflicts with 'ruff format'
# ignore some questionable pandas-vet warnings
# "PD005", # use operator instead of method
# "PD008", # We use at() to access single values
# "PD009", # And we use iat()
"PLE1205", # logging-too-many-args - we use loguru with '{' style of placeholders
"PLR0912", # Too many branches (15 > 12)
"PLR0913", # Too many arguments to function call (6 > 5)
"PLR0915", # Too many statements (65 > 50)
"PLR2004", # magic number - don't want declare 0.0 as constant
"PLR5501", # Consider using `elif` instead of `else` then `if` to remove one indentation level
"PT019", # Fixture `_bin` without value is injected as parameter (false positive?)
"S101", # Use of `assert` detected - TODO - replace assert statements with exception raise
# "S301", # `pickle` and modules that wrap... - TODO - use sql instead of pickle
# "SLF001", # Private member accessed: `_geometry_spec`
"TCH001", # Move application import `mckit.utils.named` into a type-checking block
"TRY003", # Avoid specifying long messages outside the exception class
# "W503", # Line break before binary operator: for compatibility with black settings
]
[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = ["E402", "F401"]
"benchmarks/*" = ["S101"]
"noxfile.py" = ["ANN", "D202"]
"tests/*" = ["ANN", "D100", "D101", "D102", "D103", "D104", "PLR2004", "S101"]
"src/mckit/cli/*" = [
"PLE1205", # Too many arguments for `logging` format string - we use loguru in CLI modules
]
"src/mckit/_init_dynamic_libraries.py" = ["F401", "E402"]
"src/mckit/parser/*" = [
"A003",
"D",
"F811",
"F821",
"N802",
"N816", # Variable `t_ANY_ignore` in global scope should not be mixedCase
"T201", # print found
]
"tests/parser/*" = [
"A003",
"D",
"F811",
"F821",
"N802",
"N816", # Variable `t_ANY_ignore` in global scope should not be mixedCase
"T201", # print found
]
"tools/*" = ["T201", "INP001", "S603", "S607"]
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 15
[tool.ruff.lint.flake8-annotations]
mypy-init-return = true # skip return type for __init__() methods
[tool.ruff.lint.flake8-pytest-style]
parametrize-names-type = "csv"
[tool.ruff.lint.flake8-type-checking]
strict = true
[tool.ruff.lint.isort]
known-first-party = ["src"]
known-third-party = ["mpl_toolkits", "matplotlib", "numpy", "scipy", "loguru", "tqdm", "dotenv"]
default-section = "third-party"
lines-between-types = 1
required-imports = ["from __future__ import annotations"]
case-sensitive = true
section-order = [
"future",
"typing",
"standard-library",
"third-party",
"first-party",
"local-folder",
"testing"
]
[tool.ruff.lint.isort.sections]
"typing" = ["typing", "typing_extension"]
"testing" = ["tests"]
[tool.ruff.lint.pydocstyle]
convention = "google" # Use Google-style docstrings.
[tool.ruff.format]
docstring-code-format = true
[tool.jupytext]
# https://jupytext.readthedocs.io/en/latest/config.html
# Pair ipynb notebooks to py:percent text notebooks
formats = "ipynb,md,py:percent"