Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
os: ['ubuntu-latest']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup conda
uses: s-weigand/setup-conda@v1
with:
Expand All @@ -37,5 +39,3 @@ jobs:
- name: Test
run: |
pytest tests


5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies = [
"networkx>=2.7.1",
"numpy>=1.21.2,<2",
"scipy>=1.8.0",
"plams>2025,<=2025.299",
# SCM deps are injected dynamically by scm_metadata_hook.py
]

[project.optional-dependencies]
Expand Down Expand Up @@ -66,6 +66,9 @@ source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "src/scm/pyzacros/version.py"

[tool.hatch.metadata.hooks.custom]
path = "scm_metadata_hook.py"

[tool.scm]
copy-to-target = ["examples/**/*", "tests/**/*", "../zacros_manual/ZacrosManual.pdf"]
copy-to-target-path-mappings = {"../zacros_manual/" = "doc/"}
Expand Down
25 changes: 25 additions & 0 deletions scm_metadata_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Metadata hook required for correct automatic versioning of SCM Python deps.

We constrain deps to > the last major version and <= the current tag to allow .dev builds.
Example: 2025.207.dev4 < 2025.207, so <= 2025.207 includes dev releases.
"""
from __future__ import annotations

from hatchling.metadata.plugin.interface import MetadataHookInterface
from packaging.version import Version


class ScmDependenciesMetadataHook(MetadataHookInterface):
def update(self, metadata):
raw_version = metadata["version"]
version = Version(raw_version)

base_version = version.base_version
major_version = version.major

scm_dependencies = [
f"plams>{major_version},<={base_version}",
]

metadata["dependencies"].extend(scm_dependencies)