From 5050e518baabc8b6ca27db90aee7a78aa3bf12da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20St=C3=B6cker?= Date: Fri, 26 Jun 2026 14:02:59 +0200 Subject: [PATCH] auto publish --- .github/workflows/wheels.yml | 6 +++++ .gitignore | 1 + README.md | 12 ++-------- pyproject.toml | 12 ++++++++-- rayx/__init__.py | 9 ++++--- tests/test_data.py | 8 +++---- tests/test_init.py | 4 ++++ tests/test_orientation.py | 2 +- uv.lock | 46 ++++++++++++++++++++++++++++++++++-- 9 files changed, 76 insertions(+), 24 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index cbd4861..32baf4a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -7,6 +7,9 @@ on: push: branches: - main + tags: + - 'v*.*.*' + jobs: build_wheels: @@ -34,6 +37,9 @@ jobs: # env: # CIBW_SOME_OPTION: value # ... + - name: Upload to PyPI + run: python -m twine upload --repository pypi wheelhouse/*.whl + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - uses: actions/upload-artifact@v6 with: diff --git a/.gitignore b/.gitignore index 4fc4e28..c82bdae 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ venv/ .venv/ **.so __pycache__/ +rayx/_version.py diff --git a/README.md b/README.md index edae6fe..94aaa7a 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,8 @@ The 2. option builds the package as a wheel. The resulting wheel can be installe ### Running tests -```bash -uv run pytest tests -``` - -## Release - -Wheels are built using [cibuildwheel](https://cibuildwheel.readthedocs.io/) inside a custom manylinux container with CUDA support: +To run the tests you need to build the package with cmake. ```bash -pipx run cibuildwheel +uv run pytest tests ``` - -Built wheels are placed in `wheelhouse/`. See `pyproject.toml` for the build configuration. diff --git a/pyproject.toml b/pyproject.toml index d86eea4..bcafbdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rayx" -version = "0.4.6" +dynamic = ["version"] description = "Python bindings for RAYX" readme = "README.md" license = { file = "LICENSE" } @@ -27,6 +27,11 @@ build-backend = "scikit_build_core.build" [tool.scikit-build] wheel.packages = ["python/rayx"] cmake.build-type = "Release" +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" +sdist.include = ["rayx/_version.py"] + +[tool.setuptools_scm] # Section required +write_to = "rayx/_version.py" [tool.cibuildwheel] archs = ["x86_64"] @@ -40,4 +45,7 @@ pythonpath = ["python"] package = false [dependency-groups] -dev = ["twine>=6.2.0"] +dev = [ + "setuptools-scm>=10.2.0", + "twine>=6.2.0", +] diff --git a/rayx/__init__.py b/rayx/__init__.py index ad67837..dadb78b 100644 --- a/rayx/__init__.py +++ b/rayx/__init__.py @@ -10,7 +10,7 @@ try: from . import core - from .core import * + from core import * except ImportError: # If the import fails, we might be in a development environment where the module is not built yet # We can try to import from the build directory @@ -25,11 +25,11 @@ else: raise ImportError("Could not import the RAYX C++ extension module. Make sure it is built and available.") - +from ._version import * def get_info(): - """Get information about the RAYX installation""" + "Get information about the RAYX installation" info = { "version": __version__, "python_wrapper": True, @@ -39,8 +39,7 @@ def get_info(): return info # From other files -from .data import rays_to_df +from .data import * __name__ = "rayx" -__version__ = "0.4.3" __all__ = ['get_info', 'rays_to_df'] \ No newline at end of file diff --git a/tests/test_data.py b/tests/test_data.py index 1e111b6..d18ef26 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -4,7 +4,7 @@ import pytest import pandas as pd -sys.path.insert(0, str(Path(__file__).parent.parent / "python")) +sys.path.insert(0, str(Path(__file__).parent.parent)) import rayx @@ -27,12 +27,12 @@ def test_rays_to_df_returns_dataframe(df): def test_rays_to_df_default_columns(df): expected_columns = [ - "path_event_id", + "path_id", "path_event_id", "position_x", "position_y", "position_z", "direction_x", "direction_y", "direction_z", "electric_field_x", "electric_field_y", "electric_field_z", - "energy", "order", - "last_element_id", "source_id", + "optical_path_length", "energy", "order", + "object_id", "source_id", "event_type", ] assert list(df.columns) == expected_columns diff --git a/tests/test_init.py b/tests/test_init.py index 1700e11..06eef1b 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -1,6 +1,10 @@ # tests/test_init.py import pytest from pathlib import Path +import sys + +sys.path.insert(0, str(Path(__file__).parent.parent)) + import rayx diff --git a/tests/test_orientation.py b/tests/test_orientation.py index 94ce5fd..79a97b5 100644 --- a/tests/test_orientation.py +++ b/tests/test_orientation.py @@ -11,7 +11,7 @@ import numpy as np import pytest -sys.path.insert(0, str(Path(__file__).parent.parent / "python")) +sys.path.insert(0, str(Path(__file__).parent.parent)) import rayx diff --git a/uv.lock b/uv.lock index 9ae785b..4ae2e78 100644 --- a/uv.lock +++ b/uv.lock @@ -2581,7 +2581,6 @@ wheels = [ [[package]] name = "rayx" -version = "0.4.4" source = { virtual = "." } dependencies = [ { name = "matplotlib", version = "3.9.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, @@ -2613,6 +2612,7 @@ test = [ [package.dev-dependencies] dev = [ + { name = "setuptools-scm" }, { name = "twine" }, ] @@ -2631,7 +2631,10 @@ requires-dist = [ provides-extras = ["dev", "test"] [package.metadata.requires-dev] -dev = [{ name = "twine", specifier = ">=6.2.0" }] +dev = [ + { name = "setuptools-scm", specifier = ">=10.2.0" }, + { name = "twine", specifier = ">=6.2.0" }, +] [[package]] name = "readme-renderer" @@ -2762,6 +2765,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b7/46/f5af3402b579fd5e11573ce652019a67074317e18c1935cc0b4ba9b35552/secretstorage-3.5.0-py3-none-any.whl", hash = "sha256:0ce65888c0725fcb2c5bc0fdb8e5438eece02c523557ea40ce0703c266248137", size = 15554, upload-time = "2025-11-23T19:02:51.545Z" }, ] +[[package]] +name = "setuptools" +version = "82.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4f/db/cfac1baf10650ab4d1c111714410d2fbb77ac5a616db26775db562c8fab2/setuptools-82.0.1.tar.gz", hash = "sha256:7d872682c5d01cfde07da7bccc7b65469d3dca203318515ada1de5eda35efbf9", size = 1152316, upload-time = "2026-03-09T12:47:17.221Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9d/76/f789f7a86709c6b087c5a2f52f911838cad707cc613162401badc665acfe/setuptools-82.0.1-py3-none-any.whl", hash = "sha256:a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb", size = 1006223, upload-time = "2026-03-09T12:47:15.026Z" }, +] + +[[package]] +name = "setuptools-scm" +version = "10.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, + { name = "setuptools" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, + { name = "vcs-versioning" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/61/fb/6b22ba201305ec33fa68c1419e984abe1aaee1b236a5e1186cc805738e95/setuptools_scm-10.2.0.tar.gz", hash = "sha256:ec8ea1738b92e42146a46e29a0e9de9ad462744c63cf9778677b95dfd605adde", size = 67319, upload-time = "2026-06-25T05:27:10.243Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/46/b4/21180f6fbbf7ed2043bc353608c7b9cc6f7b3d342ad8c287a097e5ca8477/setuptools_scm-10.2.0-py3-none-any.whl", hash = "sha256:6cc5ac7da8e54d74e43503be2fa023eb7a1ca820d5c318e6ae20efc48110d6c7", size = 27741, upload-time = "2026-06-25T05:27:09.037Z" }, +] + [[package]] name = "six" version = "1.17.0" @@ -2920,6 +2948,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7f/3e/5db95bcf282c52709639744ca2a8b149baccf648e39c8cc87553df9eae0c/urllib3-2.7.0-py3-none-any.whl", hash = "sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897", size = 131087, upload-time = "2026-05-07T16:13:17.151Z" }, ] +[[package]] +name = "vcs-versioning" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ea/09/6702475a5d382a432201d20b9be733f2981e7b364f4ff03296f534d9f96f/vcs_versioning-2.2.0.tar.gz", hash = "sha256:532dd99dd85e6f17667d5ca9a028b494a6e0d65dbc9d92716f1d0401078be6a0", size = 132140, upload-time = "2026-06-25T05:26:14.268Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/4c/f638c153a62e566c3e0e43f3998f8f97d4c3daadc984bb540461eaa8edf3/vcs_versioning-2.2.0-py3-none-any.whl", hash = "sha256:69a649bfbbe9f8134e8b15cddc7b27daa00e5eccbcb5128e060a87e94bad8255", size = 108104, upload-time = "2026-06-25T05:26:12.857Z" }, +] + [[package]] name = "wcwidth" version = "0.6.0"