From a2d8d92df811c6b32d7f91ccb4955310eada165a Mon Sep 17 00:00:00 2001 From: Fabian Peddinghaus Date: Sat, 9 May 2026 14:05:44 +0200 Subject: [PATCH] Source version from git tags via setuptools-scm Eliminates the dual-update workflow where pyproject.toml and CMakeLists.txt had to be edited together for every release. The version now flows from `git tag vX.Y.Z` through setuptools-scm and scikit-build-core into CMake via SKBUILD_PROJECT_VERSION, so both the Python package metadata and CMake's PROJECT_VERSION read the same value. Between releases, builds get a PEP 440 dev version automatically (e.g. 0.3.0.post1.dev0+gHASH). --- CMakeLists.txt | 10 +++++++++- pyproject.toml | 11 +++++++++-- uv.lock | 1 - 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7598afd..31d2ebe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,15 @@ cmake_minimum_required(VERSION 3.18...3.30) + +# Version is sourced from setuptools-scm via scikit-build-core (git tags). +# Fallback only applies for standalone CMake invocations outside the build +# backend. +if(NOT DEFINED SKBUILD_PROJECT_VERSION) + set(SKBUILD_PROJECT_VERSION "0.0.0") +endif() + project( OmniMalloc - VERSION 0.3.0 # Also update pyproject.toml + VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) diff --git a/pyproject.toml b/pyproject.toml index de71e4f..8086959 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["scikit-build-core>=0.11", "nanobind>=2.0"] +requires = ["scikit-build-core>=0.11", "nanobind>=2.0", "setuptools-scm>=8"] build-backend = "scikit_build_core.build" [project] name = "omnimalloc" -version = "0.3.0" # Also update CMakeLists.txt +dynamic = ["version"] description = "Your one-stop shop for static memory allocation." readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.10" @@ -65,6 +65,13 @@ build-dir = "build/{wheel_tag}" sdist.include = ["src/cpp/**"] sdist.exclude = [".github", "notebooks", "external"] +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.setuptools_scm" + +[tool.setuptools_scm] +version_scheme = "no-guess-dev" +local_scheme = "dirty-tag" + [tool.cibuildwheel] build = "cp310-* cp311-* cp312-* cp313-*" skip = "*-musllinux_*" diff --git a/uv.lock b/uv.lock index 3ed3c5a..2fc0154 100644 --- a/uv.lock +++ b/uv.lock @@ -1551,7 +1551,6 @@ wheels = [ [[package]] name = "omnimalloc" -version = "0.2.0" source = { editable = "." } dependencies = [ { name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },