From 66b7df361ae41353caf28810c02cb4e0d4768e37 Mon Sep 17 00:00:00 2001 From: Dr Alex Meakins Date: Tue, 22 Jul 2025 23:12:06 +0100 Subject: [PATCH 1/2] Moved to setuptools-scm for automatic versioning. --- .gitignore | 4 +++- dev/root-meson.build | 5 ++++- dev/update_version.sh | 2 ++ meson.build | 5 ++++- pyproject.toml | 7 +++++-- raysect/VERSION | 1 - raysect/__init__.py | 6 +----- raysect/meson.build | 4 ++-- 8 files changed, 21 insertions(+), 13 deletions(-) create mode 100755 dev/update_version.sh delete mode 100644 raysect/VERSION diff --git a/.gitignore b/.gitignore index 590e1871..9da6040c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ # C extensions *.so *.c + # Distribution / packaging .Python env/ @@ -59,4 +60,5 @@ docs/build/ # PyBuilder target/ - +# setuptools-scm +raysect/_version.py diff --git a/dev/root-meson.build b/dev/root-meson.build index 98253b94..f77fa44a 100644 --- a/dev/root-meson.build +++ b/dev/root-meson.build @@ -1,4 +1,7 @@ -project('raysect', 'cython', default_options: ['python.install-env=auto']) +project('raysect', 'cython', + default_options: ['python.install-env=auto'], + version: run_command(['dev/update_version.sh'], check: true).stdout().strip() +) py = import('python').find_installation(pure: false) numpy = dependency('numpy', method: 'config-tool') diff --git a/dev/update_version.sh b/dev/update_version.sh new file mode 100755 index 00000000..f167ea3a --- /dev/null +++ b/dev/update_version.sh @@ -0,0 +1,2 @@ +#!/bin/bash +python -m setuptools_scm --force-write-version-files diff --git a/meson.build b/meson.build index 3a2b2cf0..7c309e19 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,10 @@ # WARNING: This file is automatically generated by dev/generate_meson_files.py. # The template file used to generate this file is dev/root-meson.build. -project('raysect', 'cython', default_options: ['python.install-env=auto']) +project('raysect', 'cython', + default_options: ['python.install-env=auto'], + version: run_command(['dev/update_version.sh'], check: true).stdout().strip() +) py = import('python').find_installation(pure: false) numpy = dependency('numpy', method: 'config-tool') diff --git a/pyproject.toml b/pyproject.toml index b16903e1..4998820c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [project] name = "raysect" -version = "0.9.0" requires-python = ">=3.9" authors = [{name = "Dr Alex Meakins et al.", email = "developers@raysect.org"}] description = "A Ray-tracing Framework for Science and Engineering" @@ -19,6 +18,7 @@ classifiers = [ "Topic :: Multimedia :: Graphics :: 3D Rendering", "Topic :: Scientific/Engineering :: Physics" ] +dynamic = ["version"] [project.urls] Homepage = "https://www.raysect.org" @@ -27,5 +27,8 @@ Issues = "https://github.com/raysect/source/issues" Changelog = "https://github.com/raysect/source/blob/master/CHANGELOG.txt" [build-system] -requires = ["meson-python", "setuptools", "wheel", "numpy", "cython>=3.1"] +requires = ["meson-python", "setuptools", "wheel", "numpy", "cython>=3.1", "setuptools-scm"] build-backend = "mesonpy" + +[tool.setuptools_scm] +version_file = "raysect/_version.py" \ No newline at end of file diff --git a/raysect/VERSION b/raysect/VERSION deleted file mode 100644 index 899f24fc..00000000 --- a/raysect/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.9.0 \ No newline at end of file diff --git a/raysect/__init__.py b/raysect/__init__.py index 0e09c122..27213b8b 100644 --- a/raysect/__init__.py +++ b/raysect/__init__.py @@ -27,8 +27,4 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from os import path as _path - -# parse the package version number -with open(_path.join(_path.dirname(__file__), 'VERSION')) as _f: - __version__ = _f.read().strip() +from ._version import * diff --git a/raysect/meson.build b/raysect/meson.build index 4f55056a..eb654f3a 100644 --- a/raysect/meson.build +++ b/raysect/meson.build @@ -4,10 +4,10 @@ target_path = 'raysect' # source files -py_files = ['__init__.py'] +py_files = ['__init__.py', '_version.py'] pyx_files = [] pxd_files = [] -data_files = ['VERSION'] +data_files = [] # compile cython foreach pyx_file: pyx_files From 027aca822cff2653a34b82050c35b58813bdc0ad Mon Sep 17 00:00:00 2001 From: Dr Alex Meakins Date: Tue, 22 Jul 2025 23:16:10 +0100 Subject: [PATCH 2/2] Add setuptools-scm to dependencies. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af832884..9734d021 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: python -m pip install --prefer-binary meson-python meson ninja setuptools "cython>=3.1" "matplotlib>=3,<4" ${{ matrix.numpy-version }} + run: python -m pip install --prefer-binary meson-python meson ninja setuptools setuptools-scm "cython>=3.1" "matplotlib>=3,<4" ${{ matrix.numpy-version }} - name: Build and install Raysect run: dev/install_editable.sh - name: Run tests