-
Notifications
You must be signed in to change notification settings - Fork 523
/
pyproject.toml
461 lines (414 loc) · 13.6 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
[build-system]
requires = [
# TODO: unpin the upper bound when scikit-build dynamic metadata API is stable
# dynamic metadata API is still unstable
"scikit-build-core>=0.5,<0.11,!=0.6.0",
"packaging",
'tomli >= 1.1.0 ; python_version < "3.11"',
]
build-backend = "backend.dp_backend"
backend-path = ["."]
[project]
name = "deepmd-kit"
dynamic = ["version", "optional-dependencies", "scripts", "readme"]
description = "A deep learning package for many-body potential energy representation and molecular dynamics"
authors = [
{name = "DeepModeling"},
{name = "Han Wang", email = "wang_han@iapcm.ac.cn"},
]
license = {file = "LICENSE"}
classifiers = [
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Development Status :: 5 - Production/Stable",
"Programming Language :: C",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
"Environment :: GPU :: NVIDIA CUDA :: 12 :: 12.2",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Chemistry",
"Environment :: Console",
]
dependencies = [
# array-api-compat requires numpy>=1.21
'numpy>=1.21',
'scipy',
'pyyaml',
'dargs >= 0.4.7',
'typing_extensions; python_version < "3.8"',
'importlib_metadata>=1.4; python_version < "3.8"',
'h5py',
"h5py>=3.6.0,!=3.11.0; platform_system=='Linux' and platform_machine=='aarch64'",
'wcmatch',
'packaging',
'ml_dtypes',
'mendeleev',
'array-api-compat',
]
requires-python = ">=3.9"
keywords = ["deepmd"]
[project.entry-points."lammps.plugins"]
deepmd = "deepmd.tf.lmp:get_op_dir"
[project.entry-points."dpgui"]
"DeePMD-kit" = "deepmd.utils.argcheck:gen_args"
"DeePMD-kit Multi-task" = "deepmd.utils.argcheck:gen_args_multi_task"
[project.entry-points."dpdata.plugins"]
deepmd_driver = "deepmd.driver:DPDriver"
[project.urls]
Homepage = "https://github.com/deepmodeling/deepmd-kit"
documentation = "https://docs.deepmodeling.com/projects/deepmd"
repository = "https://github.com/deepmodeling/deepmd-kit"
# Metadata below is dynamic. However, it still has static parts,
# which can be read by the build backend.
[tool.deepmd_build_backend.optional-dependencies]
test = [
"dpdata>=0.2.7",
# ASE issue: https://gitlab.com/ase/ase/-/merge_requests/2843
# fixed in 3.23.0
"ase>=3.23.0",
"pytest",
"pytest-cov",
"pytest-sugar",
"pytest-split",
"dpgui",
'array-api-strict>=2,!=2.1.1;python_version>="3.9"',
]
docs = [
"sphinx>=3.1.1",
"sphinx-book-theme",
"myst-nb>=1.0.0rc0",
"myst-parser>=0.19.2",
"sphinx-design",
"breathe",
"exhale>=0.3.7",
"numpydoc",
"ase",
"deepmodeling-sphinx>=0.3.0",
"dargs>=0.3.4",
"sphinx-argparse<0.5.0",
"pygments-lammps",
"sphinxcontrib-bibtex",
"sphinx-autoapi>=3.0.0",
"sphinxcontrib-programoutput",
"sphinxcontrib-moderncmakedomain",
"sphinx-remove-toctrees",
]
lmp = [
"lammps~=2024.8.29.1.0",
]
ipi = [
"ipi",
]
gui = [
"dpgui",
]
cu11 = [
"nvidia-cuda-runtime-cu11",
"nvidia-cublas-cu11",
"nvidia-cufft-cu11",
"nvidia-curand-cu11",
"nvidia-cusolver-cu11",
"nvidia-cusparse-cu11",
"nvidia-cudnn-cu11<9",
"nvidia-cuda-nvcc-cu11",
]
cu12 = [
"nvidia-cuda-runtime-cu12",
"nvidia-cublas-cu12",
"nvidia-cufft-cu12",
"nvidia-curand-cu12",
"nvidia-cusolver-cu12",
"nvidia-cusparse-cu12",
"nvidia-cudnn-cu12",
"nvidia-cuda-nvcc-cu12",
]
jax = [
# below is a funny workaround for
# https://github.com/astral-sh/uv/issues/8601
'jax>=0.4.33;python_version>="3.10"',
'jax>=0.4.33;python_version>="3.10"',
'flax>=0.10.0;python_version>="3.10"',
'flax>=0.10.0;python_version>="3.10"',
'orbax-checkpoint;python_version>="3.10"',
'orbax-checkpoint;python_version>="3.10"',
# The pinning of ml_dtypes may conflict with TF
# 'jax-ai-stack;python_version>="3.10"',
]
[tool.deepmd_build_backend.scripts]
dp = "deepmd.main:main"
[dependency-groups]
dev = [
"pre-commit",
"cmake",
"mpich",
]
[tool.setuptools_scm]
[tool.scikit-build]
experimental = true
minimum-version = "0.5"
cmake.source-dir = "source"
sdist.include = [
"/deepmd/_version.py",
]
sdist.exclude = [
"/source/tests",
"/source/api_c/tests",
"/source/api_cc/tests",
"/source/lib/tests",
"/source/lmp/tests",
"/doc",
"/examples",
"/data",
"/.github",
]
wheel.packages = [
"deepmd",
]
wheel.py-api = "py37"
build-dir = "build/{wheel_tag}"
[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.setuptools_scm"
[tool.scikit-build.metadata.optional-dependencies]
provider = "backend.dynamic_metadata"
provider-path = "backend"
[tool.scikit-build.metadata.scripts]
provider = "backend.dynamic_metadata"
provider-path = "backend"
[tool.scikit-build.metadata.readme]
provider = "scikit_build_core.metadata.fancy_pypi_readme"
[[tool.scikit-build.generate]]
path = "deepmd/_version.py"
template = '''
version = "${version}"
'''
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.md"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# links
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
replacement = '[\1](https://github.com/deepmodeling/deepmd-kit/tree/master/\g<2>)'
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# image
pattern = '(srcset|src)="((?!https?://)\S+?)"'
replacement = '\1="https://github.com/deepmodeling/deepmd-kit/raw/master/\g<2>"'
[tool.cibuildwheel]
test-command = [
"python -m deepmd -h",
"""python -c "import deepmd.tf;import deepmd.pt" """,
"dp -h",
"dp_ipi",
"pytest {project}/source/tests/tf/test_lammps.py"
]
test-extras = ["cpu", "test", "lmp", "ipi", "torch"]
build = ["cp311-*"]
skip = ["*-win32", "*-manylinux_i686", "*-musllinux*"]
# TODO: uncomment to use the latest image when CUDA 11 is deprecated
# manylinux-x86_64-image = "manylinux_2_28"
manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:2022-11-19-1b19e81"
manylinux-aarch64-image = "manylinux_2_28"
[tool.cibuildwheel.macos]
before-all = [
'''pip install -i https://pypi.anaconda.org/mpi4py/simple mpich''',
]
repair-wheel-command = """delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies"""
[tool.cibuildwheel.macos.environment]
PIP_PREFER_BINARY = "1"
DP_LAMMPS_VERSION = "stable_29Aug2024_update1"
DP_ENABLE_IPI = "1"
DP_ENABLE_PYTORCH = "1"
# for unclear reason, when enabling PyTorch, OpenMP is found accidentally
CMAKE_ARGS = "-DCMAKE_DISABLE_FIND_PACKAGE_OpenMP=1"
[[tool.cibuildwheel.overrides]]
# error: 'value' is unavailable: introduced in macOS 10.13
select = "*-macosx_x86_64"
inherit.environment = "append"
environment.MACOSX_DEPLOYMENT_TARGET = "10.13"
[tool.cibuildwheel.linux]
repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so --exclude _pywrap_tensorflow_internal.so --exclude libtensorflow_cc.so.2 --exclude libc10.so --exclude libtorch.so --exclude libtorch_cpu.so -w {dest_dir} {wheel}"
environment-pass = [
"CIBW_BUILD",
"DP_VARIANT",
"CUDA_VERSION",
"DP_PKG_NAME",
"SETUPTOOLS_SCM_PRETEND_VERSION",
]
before-all = [
"""if [ ! -z "${DP_PKG_NAME}" ]; then sed -i "s/name = \\"deepmd-kit\\"/name = \\"${DP_PKG_NAME}\\"/g" pyproject.toml; fi""",
# https://almalinux.org/blog/2023-12-20-almalinux-8-key-update/
"""rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux""",
"""{ if [ "$(uname -m)" = "x86_64" ] ; then yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-nvcc-${CUDA_VERSION/./-} cuda-cudart-devel-${CUDA_VERSION/./-}; fi }""",
'''/opt/python/cp311-cp311/bin/python -m pip install -i https://pypi.anaconda.org/mpi4py/simple mpich''',
# uv is not available in the old manylinux image
"""{ if [ "$(uname -m)" = "x86_64" ] ; then pipx install uv; fi }""",
]
before-build = [
# old build doesn't support uv
"""{ if [ "$(uname -m)" = "x86_64" ] ; then uv pip install --system -U build; fi }""",
]
[tool.cibuildwheel.linux.environment]
PIP_PREFER_BINARY = "1"
DP_LAMMPS_VERSION = "stable_29Aug2024_update1"
DP_ENABLE_IPI = "1"
DP_ENABLE_PYTORCH = "1"
MPI_HOME = "/usr/lib64/mpich"
PATH = "/usr/lib64/mpich/bin:$PATH"
# use CPU version of torch for building, which should also work for GPU
# note: uv has different behavior from pip on extra index url
# https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY.md#packages-that-exist-on-multiple-indexes
UV_EXTRA_INDEX_URL = "https://download.pytorch.org/whl/cpu"
# trick to find the correction version of mpich
CMAKE_PREFIX_PATH="/opt/python/cp311-cp311/"
[tool.cibuildwheel.windows]
test-extras = ["cpu", "torch"]
test-command = [
"python -m deepmd -h",
"dp -h",
]
[tool.cibuildwheel.windows.environment]
PIP_PREFER_BINARY = "1"
DP_ENABLE_PYTORCH = "1"
# One can run `tox` or `tox -e gpu`
# to run pytest in an isolated environment
# Use with pipx:
# $ pip install -U pipx
# $ pipx tox
[tool.tox]
legacy_tox_ini = """
[tox]
min_version = 4.0
[testenv]
extras =
test
cpu
commands = pytest source/tests
[testenv:gpu]
extras =
test
gpu
commands = pytest source/tests
setenv =
DP_VARIANT = cuda
"""
# selectively turn of lintner warnings, always include reasoning why any warning should
# be silenced
# W504 - line break after binary operator - there is conflict between W503 and W504 in
# some lintners. One recommends line bread after and one before binary operator so we
# switch W504 off and recommend this coding style:
# a = (b + -> instead of -> a = (b
# c) + c)
[tool.autopep8]
ignore = "W504"
# D413 - Missing blank line after last section - makes no sense only adds empty lines in
# docstrings
# D416 - Section name should end with a colon - only applicable to RST type docstrings,
# we are using numpy style
# D203 - 1 blank line required before class docstring - only adds unnecessary empty space
# D107 - Missing docstring in __init__ - Nupmy style documents __init__ parameters in
# class docstring
# D213 - Multi-line docstring summary should start at the second line - unnecessary waste
# of space, start on the first line
[tool.pydocstyle]
ignore = "D413, D416, D203, D107, D213"
[tool.isort]
profile = "black"
force_grid_wrap = 1
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint]
select = [
"E", # errors
"W", # warning
"F", # pyflakes
"D", # pydocstyle
"UP", # pyupgrade
"C4", # flake8-comprehensions
"RUF", # ruff
"NPY", # numpy
"TID251", # banned-api
"TID253", # banned-module-level-imports
"T20", # ban print
"B904", # raise-without-from-inside-except
"N804", # invalid-first-argument-name-for-class-method
"N805", # invalid-first-argument-name-for-method
"DTZ", # datetime
"TCH", # flake8-type-checking
"PYI", # flake8-pyi
]
ignore = [
"E501", # line too long
"F841", # local variable is assigned to but never used
"E741", # ambiguous variable name
"E402", # module level import not at top of file
"D100", # TODO: missing docstring in public module
"D101", # TODO: missing docstring in public class
"D102", # TODO: missing docstring in public method
"D103", # TODO: missing docstring in public function
"D104", # TODO: missing docstring in public package
"D105", # TODO: missing docstring in magic method
"D205", # 1 blank line required between summary line and description
"D401", # TODO: first line should be in imperative mood
"D404", # TODO: first word of the docstring should not be This
]
ignore-init-module-imports = true
exclude = [
"source/3rdparty/**",
]
[tool.ruff.lint.pydocstyle]
convention = "numpy"
[tool.ruff.lint.flake8-tidy-imports]
banned-module-level-imports = [
"deepmd.tf",
"deepmd.pt",
"deepmd.jax",
"tensorflow",
"torch",
"jax",
]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"torch.testing.assert_allclose".msg = "Use `torch.testing.assert_close()` instead, see https://github.com/pytorch/pytorch/issues/61844."
[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = ["torch.nn.Module"]
[tool.ruff.lint.extend-per-file-ignores]
# Also ignore `E402` in all `__init__.py` files.
"deepmd/tf/**" = ["TID253"]
"deepmd/pt/**" = ["TID253"]
"deepmd/jax/**" = ["TID253"]
"source/tests/tf/**" = ["TID253"]
"source/tests/pt/**" = ["TID253"]
"source/tests/jax/**" = ["TID253"]
"source/tests/universal/pt/**" = ["TID253"]
"source/jax2tf_tests/**" = ["TID253"]
"source/ipi/tests/**" = ["TID253"]
"source/lmp/tests/**" = ["TID253"]
"**/*.ipynb" = ["T20"] # printing in a nb file is expected
[tool.pytest.ini_options]
markers = "run"
[tool.coverage.run]
plugins = ["source.3rdparty.coverage_plugins.jit_plugin"]
[tool.pylint.'MESSAGES CONTROL']
load-plugins = "deepmd_checker"
disable = "all"
enable = "E8001,E8002"
[tool.flake8]
select = [
"TOR0",
"TOR1",
"TOR2",
]
[tool.uv.sources]
mpich = { index = "mpi4py" }
openmpi = { index = "mpi4py" }
[[tool.uv.index]]
name = "mpi4py"
url = "https://pypi.anaconda.org/mpi4py/simple"
explicit = true