Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): move static part of dynamic metadata to pyproject.toml #3618

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 20 additions & 62 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,75 +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.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.2.7",
"ase",
"pytest",
"pytest-cov",
"pytest-sugar",
"dpgui",
"mendeleev",
],
"docs": [
"sphinx>=3.1.1",
"sphinx_rtd_theme>=1.0.0rc1",
"sphinx_markdown_tables",
"myst-nb>=1.0.0rc0",
"myst-parser>=0.19.2",
"sphinx-design",
"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",
],
"torch": [
"torch>=2a",
],
}
66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ requires = [
# dynamic metadata API is still unstable
"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 @@ -63,6 +64,71 @@ 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",
"mendeleev",
]
docs = [
"sphinx>=3.1.1",
"sphinx_rtd_theme>=1.0.0rc1",
"sphinx_markdown_tables",
"myst-nb>=1.0.0rc0",
"myst-parser>=0.19.2",
"sphinx-design",
"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",
]
torch = [
"torch>=2a",
]

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

[tool.setuptools_scm]

[tool.scikit-build]
Expand Down