Skip to content

build(cmake): only allow to build as python extension - #152

Open
robertodr wants to merge 49 commits into
mainfrom
chore-dev-single-build-path
Open

build(cmake): only allow to build as python extension#152
robertodr wants to merge 49 commits into
mainfrom
chore-dev-single-build-path

Conversation

@robertodr

@robertodr robertodr commented Jul 24, 2026

Copy link
Copy Markdown
Member

By opening this PR I confirm that I have read CONTRIBUTING.md and I agree to the terms of the Contributor License Agreement.

Summary

This project is purely a Python extension but the build system, and configuration around it, still offered the (vestigial) option of building as a C++-only project.

Re-hash of #106, where I made a hideous mistake with the git history.

Changes

  • Remove CMake code that allowed to build as a standalone C++ project, as that is no longer meaningful. A warning is issued against compiling with direct invocation to CMake.

  • C++ unit tests are gated behind a new CMake option monoprop_ENABLE_CXX_UNIT_TESTS, which is ON by default.

  • CMakePresets.json changed accordingly, as it's effectively only needed for test autodiscovery.

  • Edit justfile to account for loss of many presets for CMake.

  • Overhaul CMake code for installation of artifacts. The package is installed under lib/python3.X/site-packages/monoprop all other artifacts are installed in subfolders of it:

    • libmonoprop.so is under lib (or lib64, depending on the machine)
    • all headers are under include with the proper hierarchical folder structure
    • CMake helper files are under cmake The header files are now explicitly listed (instead of globbed) and we use target_sources with FILE_SET pento handle them sanely (instead of appending to a global list)

    I have dropped the distinction between private and public for now.

  • Simplified test.yml accordingly:

    • we no longer need separate jobs to run the C++ unit tests: they can be compiled within a wheel build and run, if need be.
    • Single coverage job running both Python and C++ tests.

Checklist

  • Tests added or updated to cover the changes
  • Documentation updated (docstrings, docs/, CONTRIBUTING.md) if needed
  • CHANGELOG / release notes updated if applicable

AI/LLM disclosure

  • I did not use LLM tooling, or used it only privately for ideation
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code: GitHub Copilot with auto-selection of model.

This is part 1 of 3 in a stack made with GitButler:

@github-actions

Copy link
Copy Markdown

Docs preview: https://pr-152.monoprop-docs.pages.dev

@robertodr
robertodr force-pushed the chore-dev-single-build-path branch 2 times, most recently from a3a3686 to a8aa7c6 Compare July 26, 2026 08:55
@robertodr robertodr changed the title build: only allow to build as python extension build(cmake): only allow to build as python extension Jul 26, 2026
Comment thread src/monoprop/bindings/CMakeLists.txt Outdated
@robertodr
robertodr force-pushed the chore-dev-single-build-path branch from 4e6f1e6 to afd0488 Compare July 26, 2026 09:37
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.31%. Comparing base (847b50f) to head (88dfbf7).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #152       +/-   ##
===========================================
+ Coverage   84.66%   95.31%   +10.64%     
===========================================
  Files          59       14       -45     
  Lines        4239      704     -3535     
  Branches     1497       88     -1409     
===========================================
- Hits         3589      671     -2918     
+ Misses        254       20      -234     
+ Partials      396       13      -383     
Flag Coverage Δ
cpp 95.31% <ø> (+12.76%) ⬆️
python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

@robertodr
robertodr force-pushed the chore-dev-single-build-path branch 3 times, most recently from ddc660a to d9fd7a3 Compare July 29, 2026 11:07
Comment thread .devcontainer/postStartCommand.sh
Comment thread .github/workflows/test.yml Outdated
@robertodr

Copy link
Copy Markdown
Member Author

The PR is still in progress, it's not marked as draft as I need all CI jobs to run on each commit to check I'm not losing functionality. Sorry for the confusion!

@robertodr
robertodr force-pushed the chore-dev-single-build-path branch 4 times, most recently from 0485838 to dad84db Compare July 29, 2026 18:59
@robertodr

Copy link
Copy Markdown
Member Author

this will also need to be merged by bypassing requirements, since the job names changed. Plus a change in required checks in the ruleset.

@robertodr
robertodr requested review from Copilot and ludmilaasb July 30, 2026 11:05
@robertodr

Copy link
Copy Markdown
Member Author

This is now ready-ready to review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the build/CI tooling to treat monoprop as a scikit-build-core–driven Python extension only, removing the remaining “standalone CMake project” pathways, and reshaping install + test/coverage flows around the editable build trees that uv sync creates.

Changes:

  • Make top-level CMake configuration scikit-build-core–centric (with direct-CMake invocation discouraged) and gate C++ unit tests behind a dedicated option.
  • Rework CMake install and header handling to use target_sources(FILE_SET ...), installing artifacts under the Python package layout.
  • Simplify developer/CI workflows (presets, VS Code tasks, just recipes, GitHub Actions) to build/test via the scikit-build-core editable trees and consolidate coverage.

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
uv.lock Removes gcovr and its transitive lock entries from the locked environment.
pyproject.toml Drops gcovr from dev deps; updates cibuildwheel env to explicitly disable C++ unit tests during wheel builds.
CMakeLists.txt Moves to scikit-build-core–first configuration, adds monoprop_ENABLE_CXX_UNIT_TESTS, and gates tests/cpp accordingly.
src/CMakeLists.txt Updates CMake package config install location and version-file generation for the new install layout.
src/monoprop/CMakeLists.txt Switches to FILE_SET-based header installation, adjusts install destinations under the Python package, and reorganizes subdirectories.
src/monoprop/bindings/CMakeLists.txt Removes local Python discovery, updates compile flag handling, and rewrites RPATH logic for the new package layout.
src/monoprop/algebra/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/core/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/CMakeLists.txt Adds explicit header listing via FILE_SET and enumerates detail subdirectories.
src/monoprop/detail/evolution/CMakeLists.txt Adds explicit header listing via FILE_SET and includes layer_build.
src/monoprop/detail/evolution/layer_build/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/graph/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/graph_encoding/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/monomial_propagator/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/mpi/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/operator/CMakeLists.txt Adds explicit header listing via FILE_SET.
src/monoprop/detail/pare/CMakeLists.txt Adds explicit header listing and adds PareGraph.cpp as a private source.
src/monoprop/detail/partition/CMakeLists.txt Adds explicit header listing via FILE_SET.
tests/cpp/CMakeLists.txt Ensures CPM is included and configures msgpack-cxx via CPM for the C++ test suite.
tests/cpp/boostAddTests.cmake Labels C++ tests with cxx for CTest filtering/reporting.
justfile Consolidates test recipes and reworks the coverage flow to run via scikit-build-core editable trees.
CMakePresets.json Replaces standalone configure/build/test presets with “adopt existing skbuild tree” presets.
.vscode/tasks.json Switches VS Code tasks to uv sync-based install modes (Release/Debug/Coverage).
.vscode/settings.json Disables CMake Tools auto-reconfigure and enables CTest Explorer integration for adopted build trees.
.github/workflows/test.yml Overhauls CI into package-centric matrix runs, adds find_package(monoprop) smoke test, runs C++ unit tests via ctest, and consolidates coverage jobs.
.github/workflows/docpages.yml Sets env to disable C++ unit tests for docs builds.
.github/workflows/copilot-setup-steps.yml Sets CPM_USE_LOCAL_PACKAGES and updates uv sync invocation for setup.
.devcontainer/postStartCommand.sh Makes prek install overwrite existing hooks in the devcontainer.

Comment thread CMakeLists.txt
Comment thread src/CMakeLists.txt
Comment thread src/monoprop/bindings/CMakeLists.txt Outdated
Comment thread justfile Outdated
Comment thread .github/workflows/test.yml Outdated
@robertodr
robertodr force-pushed the chore-dev-single-build-path branch 3 times, most recently from ae25e7c to 2587fab Compare July 30, 2026 13:25
ludmilaasb and others added 28 commits August 1, 2026 19:51
When needed, can be run as uvx gcovr, using an ephemeral environment
There is a single job running on ubuntu-26.04 with python 3.11
collecting coverage information from:
* Python tests
* C++ unit tests
* line hits from calling the C++ compiled code from the Python API
Thus avoiding a rebuild when invoking pytest
Fallout from removing most of the cmake presets
Needs lcov format, plus some workarounds, to merge the Python and C++
results.
@robertodr
robertodr force-pushed the chore-dev-single-build-path branch from edd6db8 to 88dfbf7 Compare August 1, 2026 17:52
@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants