Skip to content

Commit

Permalink
chore(build): move static part of dynamic metadata to pyproject.toml (#…
Browse files Browse the repository at this point in the history
…3618)

Signed-off-by: Jinzhe Zeng <[email protected]>
(cherry picked from commit 571bd52)
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Apr 6, 2024
1 parent 8c0f298 commit 5e8ba89
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 57 deletions.
77 changes: 20 additions & 57 deletions backend/dynamic_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import sys
from pathlib import (
Path,
)
from typing import (
Dict,
List,
Expand All @@ -12,6 +16,11 @@
get_argument_from_env,
)

if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

__all__ = ["dynamic_metadata"]


Expand All @@ -22,70 +31,24 @@ def __dir__() -> List[str]:
def dynamic_metadata(
field: str,
settings: Optional[Dict[str, object]] = None,
) -> str:
):
assert field in ["optional-dependencies", "entry-points", "scripts"]
_, _, find_libpython_requires, extra_scripts, tf_version = get_argument_from_env()
with Path("pyproject.toml").open("rb") as f:
pyproject = tomllib.load(f)

if field == "scripts":
return {
"dp": "deepmd_utils.main:main",
**pyproject["tool"]["deepmd_build_backend"]["scripts"],
**extra_scripts,
}
elif field == "optional-dependencies":
optional_dependencies = pyproject["tool"]["deepmd_build_backend"][
"optional-dependencies"
]
optional_dependencies["lmp"].extend(find_libpython_requires)
optional_dependencies["ipi"].extend(find_libpython_requires)
return {
"test": [
"dpdata>=0.1.9",
"ase",
"pytest",
"pytest-cov",
"pytest-sugar",
"dpgui",
],
"docs": [
"sphinx>=3.1.1",
"sphinx_rtd_theme>=1.0.0rc1",
"sphinx_markdown_tables",
"myst-nb>=1.0.0rc0",
"myst-parser>=0.19.2",
"breathe",
"exhale",
"numpydoc",
"ase",
"deepmodeling-sphinx>=0.1.0",
"dargs>=0.3.4",
"sphinx-argparse",
"pygments-lammps",
"sphinxcontrib-bibtex",
],
"lmp": [
"lammps~=2023.8.2.3.0",
*find_libpython_requires,
],
"ipi": [
"i-PI",
*find_libpython_requires,
],
"gui": [
"dpgui",
],
**optional_dependencies,
**get_tf_requirement(tf_version),
"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<9",
"nvidia-cuda-nvcc-cu12",
],
}
61 changes: 61 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ requires = [
# TODO: unpin the upper bound when it is stable
"scikit-build-core>=0.5,<0.9,!=0.6.0",
"packaging",
'tomli >= 1.1.0 ; python_version < "3.11"',
]
build-backend = "backend.dp_backend"
backend-path = ["."]
Expand Down Expand Up @@ -60,6 +61,66 @@ 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",
"pytest",
"pytest-cov",
"pytest-sugar",
"dpgui",
]
docs = [
"sphinx>=3.1.1",
"sphinx_rtd_theme>=1.0.0rc1",
"sphinx_markdown_tables",
"myst-nb>=1.0.0rc0",
"myst-parser>=0.19.2",
"breathe",
"exhale",
"numpydoc",
"ase",
"deepmodeling-sphinx>=0.1.0",
"dargs>=0.3.4",
"sphinx-argparse",
"pygments-lammps",
"sphinxcontrib-bibtex",
]
lmp = [
"lammps~=2023.8.2.3.0",
]
ipi = [
"i-PI",
]
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<9",
"nvidia-cuda-nvcc-cu12",
]

[tool.deepmd_build_backend.scripts]
dp = "deepmd_utils.main:main"

[tool.setuptools_scm]

[tool.scikit-build]
Expand Down

0 comments on commit 5e8ba89

Please sign in to comment.