From a9b7f6020a8ee7a4409c68a8029e302ae8ae2cf7 Mon Sep 17 00:00:00 2001 From: Fabian Zills Date: Tue, 10 Mar 2026 15:24:51 +0100 Subject: [PATCH] build: switch to hatchling + hatch-vcs and add PyPI publish workflow Replace uv_build with hatchling/hatch-vcs for automatic git-tag versioning. Add GitHub Actions workflow for publishing to PyPI on release via trusted publishing. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/publish.yaml | 42 ++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ pyproject.toml | 12 +++++++--- uv.lock | 13 +++++------ 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..2ba5a48 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,42 @@ +name: Build and upload to PyPI + +on: + workflow_dispatch: + release: + types: + - published + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: astral-sh/setup-uv@v5 + - name: Build sdist and wheel + run: uv build + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/* + + upload_pypi: + needs: [build] + environment: + name: pypi + url: https://pypi.org/p/asebytes + permissions: + id-token: write + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'published') + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index 09c44c8..ea0aa35 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ benchmark_results.json # Git worktrees .worktrees/ + +# hatch-vcs generated version file +src/asebytes/_version.py diff --git a/pyproject.toml b/pyproject.toml index bc63f89..9f4c60c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "asebytes" -version = "0.3.0" +dynamic = ["version"] description = "Fast binary serialization and storage for ASE Atoms." authors = [ { name = "Fabian Zills", email = "fzills@icp.uni-stuttgart.de" }, @@ -15,8 +15,8 @@ dependencies = [ ] [build-system] -requires = ["uv_build>=0.9.6,<0.10.0"] -build-backend = "uv_build" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" [dependency-groups] dev = [ @@ -62,6 +62,12 @@ redis = [ "redis>=5.0", ] +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/asebytes/_version.py" + [tool.pytest.ini_options] testpaths = ["tests"] python_files = ["test_*.py"] diff --git a/uv.lock b/uv.lock index b0ce766..9e8ec18 100644 --- a/uv.lock +++ b/uv.lock @@ -194,7 +194,6 @@ wheels = [ [[package]] name = "asebytes" -version = "0.3.0" source = { editable = "." } dependencies = [ { name = "ase" }, @@ -204,7 +203,7 @@ dependencies = [ ] [package.optional-dependencies] -h5md = [ +h5 = [ { name = "h5py" }, ] hf = [ @@ -227,7 +226,7 @@ zarr = [ dev = [ { name = "anyio" }, { name = "ase-db-backends" }, - { name = "asebytes", extra = ["h5md", "hf", "lmdb", "mongodb", "redis", "zarr"] }, + { name = "asebytes", extra = ["h5", "hf", "lmdb", "mongodb", "redis", "zarr"] }, { name = "ipykernel" }, { name = "matplotlib" }, { name = "molify" }, @@ -241,8 +240,8 @@ dev = [ requires-dist = [ { name = "ase", specifier = ">=3.26.0" }, { name = "datasets", marker = "extra == 'hf'", specifier = ">=4.5.0" }, - { name = "h5py", marker = "extra == 'h5md'", specifier = ">=3.8.0" }, - { name = "lmdb", marker = "extra == 'lmdb'", specifier = ">=1.7.5" }, + { name = "h5py", marker = "extra == 'h5'", specifier = ">=3.12.0" }, + { name = "lmdb", marker = "extra == 'lmdb'", specifier = ">=1.6.0" }, { name = "msgpack", specifier = ">=1.1.2" }, { name = "msgpack-numpy", specifier = ">=0.4.8" }, { name = "pymongo", marker = "extra == 'mongodb'", specifier = ">=4.13" }, @@ -250,13 +249,13 @@ requires-dist = [ { name = "typing-extensions", specifier = ">=4.5.0" }, { name = "zarr", marker = "extra == 'zarr'", specifier = ">=3.0" }, ] -provides-extras = ["lmdb", "hf", "h5md", "zarr", "mongodb", "redis"] +provides-extras = ["h5", "hf", "lmdb", "mongodb", "redis", "zarr"] [package.metadata.requires-dev] dev = [ { name = "anyio", specifier = ">=4.0" }, { name = "ase-db-backends", specifier = ">=0.10.0" }, - { name = "asebytes", extras = ["h5md"] }, + { name = "asebytes", extras = ["h5"] }, { name = "asebytes", extras = ["hf"] }, { name = "asebytes", extras = ["lmdb"] }, { name = "asebytes", extras = ["mongodb"] },