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
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/cython_cmake/cmake/UseCython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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)

Expand Down
38 changes: 38 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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])