From a9eacc052a8ad2da4514b6cf55e7f98af16d1698 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Mon, 8 Dec 2025 21:27:51 +0000 Subject: [PATCH 1/2] build and publish a wheel --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b8a769..4cb2d4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: - name: Build package run: | - python -m build --sdist + python -m build - name: Check metadata run: twine check dist/* @@ -60,4 +60,3 @@ jobs: with: name: "v${{ steps.get_version.outputs.version }}" body: "Notes: https://python-cmake.github.io/pytest-cmake/release/release_notes.html" - From 674c4eab904bf1bdd66a6a4214d1f02db56d22e5 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Fri, 2 Jan 2026 11:54:55 -0800 Subject: [PATCH 2/2] Fix Pytest config-mode version handling Keep PytestConfigVersion.cmake for config-mode checks without hard-coding a build-time pytest version. Version discovery remains dynamic via FindPytest.cmake. PytestConfig.cmake stays a thin entry point. Wheel distribution is supported. --- .github/workflows/test.yml | 1 + build_config.py | 20 +++++--------------- doc/installing.rst | 16 ---------------- doc/release/release_notes.rst | 14 +++++++++++++- pyproject.toml | 1 + test/00-version-fails/CMakeLists.txt | 5 +++++ test/CMakeLists.txt | 9 +++++++++ 7 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 test/00-version-fails/CMakeLists.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 306f21f..843e701 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,6 +63,7 @@ jobs: run: | cmake -S ./test -B ./test/build cmake --build ./test/build + ctest --test-dir ./test/build -VV -C Release - name: Configure Example shell: bash diff --git a/build_config.py b/build_config.py index b5eff50..5a39dad 100644 --- a/build_config.py +++ b/build_config.py @@ -1,7 +1,6 @@ from hatchling.builders.hooks.plugin.interface import BuildHookInterface import pathlib -import subprocess class BuildConfig(BuildHookInterface): @@ -9,7 +8,6 @@ class BuildConfig(BuildHookInterface): def initialize(self, version, build_data): """Execute builder.""" - import pytest root = pathlib.Path(__file__).parent.resolve() build_path = (root / "build") @@ -25,18 +23,10 @@ def initialize(self, version, build_data): "include(${CMAKE_CURRENT_LIST_DIR}/FindPytest.cmake)\n" ) - # Generate CMake config version file for client to target a specific - # version of Pytest within CMake projects. - version_config_path = (build_path / "PytestConfigVersion.cmake") - script_path = (build_path / "PytestConfigVersionScript.cmake") - with script_path.open("w", encoding="utf-8") as stream: + # Always accept; actual version checks are handled by FindPytest.cmake + config_path = (build_path / "PytestConfigVersion.cmake") + with config_path.open("w", encoding="utf-8") as stream: stream.write( - "include(CMakePackageConfigHelpers)\n" - "write_basic_package_version_file(\n" - f" \"{str(version_config_path.as_posix())}\"\n" - f" VERSION {pytest.__version__}\n" - " COMPATIBILITY AnyNewerVersion\n" - ")" + "set(PACKAGE_VERSION_COMPATIBLE TRUE)\n" + "set(PACKAGE_VERSION_EXACT TRUE)\n" ) - - subprocess.call(["cmake", "-P", str(script_path), "-VV"]) diff --git a/doc/installing.rst b/doc/installing.rst index 20b40b2..8774b46 100644 --- a/doc/installing.rst +++ b/doc/installing.rst @@ -61,19 +61,3 @@ View the result in your browser at:: file:///path/to/sphinx-build/build/doc/html/index.html -.. _installing/deployment: - -Package Deployment -================== - -This package is deployed as a source on `PyPi `_ -to allow dynamic adaptation of :term:`CMake` scripts based on the version of :term:`Pytest` -available at installation. Packaging it as a -`wheel `_ -would lock the :term:`Pytest` version detected during the packaging and deployment process, -reducing flexibility and compatibility with future versions. - -If you wish to deploy the package as a source within a custom index, it is important to include -the build requirements in your environment (e.g. "hatchling" and "cmake"). - -.. seealso:: `Package Formats `_ diff --git a/doc/release/release_notes.rst b/doc/release/release_notes.rst index 44d84de..013ee6b 100644 --- a/doc/release/release_notes.rst +++ b/doc/release/release_notes.rst @@ -4,6 +4,18 @@ Release Notes ************* +.. release:: Upcoming + + .. change:: changed + + Updated :term:`CMake` packaging by simplifying + `PytestConfigVersion.cmake` so that version compatibility is no longer + fixed at build time. Version discovery and validation are handled + dynamically by `FindPytest.cmake`, with `PytestConfig.cmake` serving + only as a thin entry point for :term:`CMake` package discovery. + Wheel distribution is fully supported and recommended. + Thanks :github_user:`dimbleby`! + .. release:: 1.2.0 :date: 2025-12-08 @@ -165,7 +177,7 @@ Release Notes .. change:: changed - Added documentation for :ref:`installing/deployment`. + Added documentation for deployment. .. change:: changed diff --git a/pyproject.toml b/pyproject.toml index d47d37a..8d4121b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] [project.scripts] diff --git a/test/00-version-fails/CMakeLists.txt b/test/00-version-fails/CMakeLists.txt new file mode 100644 index 0000000..a2f0b43 --- /dev/null +++ b/test/00-version-fails/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.20) + +project(TestVersionFails) + +find_package(Pytest 99.0 REQUIRED) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c53f224..63b6c63 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,8 +2,17 @@ cmake_minimum_required(VERSION 3.20) project(Test) +enable_testing() include(ExternalProject) +add_test( + NAME TestVersionFails + COMMAND ${CMAKE_COMMAND} + -S ${CMAKE_CURRENT_SOURCE_DIR}/tests/00-version-fails + -B ${CMAKE_BINARY_DIR}/_deps/00-version-fails +) +set_tests_properties(TestVersionFails PROPERTIES WILL_FAIL TRUE) + ExternalProject_Add( TestModifyName SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/01-modify-name