diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dee1a7..9df0866 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,9 @@ jobs: pipx run nox -s pylint checks: - name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} + name: + 🐍 ${{ matrix.python-version }} on ${{ matrix.runs-on }} ${{ matrix.cmake + }} runs-on: ${{ matrix.runs-on }} needs: [pre-commit] strategy: @@ -46,6 +48,12 @@ jobs: include: - python-version: pypy-3.10 runs-on: ubuntu-latest + - python-version: "3.9" + runs-on: ubuntu-latest + cmake: "3.20.x" + - python-version: "3.10" + runs-on: ubuntu-latest + cmake: "3.15.x" steps: - uses: actions/checkout@v4 @@ -57,6 +65,14 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true + - uses: jwlawson/actions-setup-cmake@v2 + if: matrix.cmake != '' + with: + cmake-version: ${{ matrix.cmake }} + + - run: pipx install ninja + if: matrix.cmake == '3.15.x' + - uses: yezz123/setup-uv@v4 - name: Install package diff --git a/src/cython_cmake/cmake/UseCython.cmake b/src/cython_cmake/cmake/UseCython.cmake index ac7b95e..1bb66d1 100644 --- a/src/cython_cmake/cmake/UseCython.cmake +++ b/src/cython_cmake/cmake/UseCython.cmake @@ -64,6 +64,9 @@ # limitations under the License. #============================================================================= +if(CMAKE_VERSION VERSION_LESS "3.7") + message(SEND_ERROR "CMake 3.7 required for DEPFILE") +endif() function(Cython_compile_pyx) set(_options ) @@ -116,7 +119,11 @@ function(Cython_compile_pyx) set(generated_files) foreach(_source_file IN LISTS _source_files) - cmake_path(GET _source_file STEM _name) + + # Can use cmake_path for CMake 3.20+ + # cmake_path(GET _source_file STEM _name) + get_filename_component(_name "${_source_file}" NAME_WE) + set(generated_file "${CMAKE_CURRENT_BINARY_DIR}/${_name}.${_language_extension}") set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..50e0aeb --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +import importlib.metadata +import shutil +import subprocess + + +def _get_program(name: str) -> str: + res = shutil.which(name) + if res is None: + return f"No {name} executable found on PATH" + result = subprocess.run( + [res, "--version"], check=True, text=True, capture_output=True + ) + version = result.stdout.splitlines()[0] + return f"{res}: {version}" + + +def pytest_report_header() -> str: + interesting_packages = { + "cmake", + "ninja", + "packaging", + "pip", + "scikit-build-core", + } + valid = [] + for package in interesting_packages: + try: + version = importlib.metadata.version(package) + except ModuleNotFoundError: + continue + valid.append(f"{package}=={version}") + reqs = " ".join(sorted(valid)) + pkg_line = f"installed packages of interest: {reqs}" + prog_lines = [_get_program(n) for n in ("cmake3", "cmake", "ninja")] + + return "\n".join([pkg_line, *prog_lines])