Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Build package
run: |
python -m build --sdist
python -m build

- name: Check metadata
run: twine check dist/*
Expand Down Expand Up @@ -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"

1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 5 additions & 15 deletions build_config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface

import pathlib
import subprocess


class BuildConfig(BuildHookInterface):
"""Builder to create and share pytest config."""

def initialize(self, version, build_data):
"""Execute builder."""
import pytest

root = pathlib.Path(__file__).parent.resolve()
build_path = (root / "build")
Expand All @@ -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"])
16 changes: 0 additions & 16 deletions doc/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://pypi.org/project/pytest-cmake/>`_
to allow dynamic adaptation of :term:`CMake` scripts based on the version of :term:`Pytest`
available at installation. Packaging it as a
`wheel <https://packaging.python.org/en/latest/specifications/binary-distribution-format>`_
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 <https://packaging.python.org/en/latest/discussions/package-formats>`_
14 changes: 13 additions & 1 deletion doc/release/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -165,7 +177,7 @@ Release Notes

.. change:: changed

Added documentation for :ref:`installing/deployment`.
Added documentation for deployment.

.. change:: changed

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions test/00-version-fails/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.20)

project(TestVersionFails)

find_package(Pytest 99.0 REQUIRED)
9 changes: 9 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down