Skip to content

Enable the C ABI library option - #109

Merged
python-templates-automerge[bot] merged 3 commits into
mainfrom
enable-c-abi-library
Nov 14, 2026
Merged

python-templates-automerge[bot] merged 3 commits into
mainfrom
enable-c-abi-library

Conversation

@timkpaine

Copy link
Copy Markdown
Member

Description

Regenerates the project from the base template with add_c_abi: true (Copier update to base c40b5eb).

  • cpp/python-template-cpp/ builds libpython_template_cpp, a C ABI over the C++ code, declared in python_template_cpp/include/python_template_cpp/python_template_cpp.h.
  • cpp/python/extension.cpp is the pybind11 extension and links the library through hatch-cpp depends.
  • cpp/CMakeLists.txt builds and installs the library without Python, with a package config and a pkg-config file.
  • The tests load the library, compile a C program against the installed package, and build a find_package consumer against the CMake install.

This requires hatch-cpp>=0.6.0. It is the first run of the option on Windows and in Pyodide, where the extension compiles the library sources in.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup
  • CI / build configuration
  • Other (describe below)

Checklist

  • Linting passes (make lint)
  • Tests pass (make test)
  • New tests added for new functionality
  • Documentation updated (if applicable)
  • Changelog / version bump (if applicable)

Regenerate from the base template with add_c_abi. The sources split into cpp/python-template-cpp, which builds libpython_template_cpp with a C surface, and cpp/python, the pybind11 extension that links it. cpp/CMakeLists.txt builds and installs the library without Python.

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
@timkpaine timkpaine closed this Nov 14, 2026
@timkpaine timkpaine reopened this Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.72222% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.36%. Comparing base (268627e) to head (92f7f3e).

Files with missing lines Patch % Lines
python_template_cpp/tests/test_all.py 83.87% 5 Missing and 5 partials ⚠️
python_template_cpp/__init__.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
+ Coverage   78.57%   85.36%   +6.79%     
==========================================
  Files           2        2              
  Lines          14       82      +68     
  Branches        0        7       +7     
==========================================
+ Hits           11       70      +59     
- Misses          3        7       +4     
- Partials        0        5       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Windows runners find MinGW gcc before cl, and the program needs the library directory on PATH either way. The same change is in python-project-templates/base#223.

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

4 tests  +3   4 ✅ +3   1s ⏱️ -1s
1 suites ±0   0 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 92f7f3e. ± Comparison against base commit 268627e.

This pull request removes 1 and adds 4 tests. Note that renamed tests count towards both.
python_template_cpp.tests.test_all.TestAll ‑ test_all
python_template_cpp.tests.test_all ‑ test_all
python_template_cpp.tests.test_all ‑ test_c_consumer_builds_against_the_installed_package
python_template_cpp.tests.test_all ‑ test_c_library_and_header_are_installed
python_template_cpp.tests.test_all ‑ test_cmake_project_installs_a_package_that_find_package_locates

♻️ This comment has been updated with latest results.

cibuildwheel runs delvewheel on Windows by default, and it cannot find the DLL the wheel already ships. The same change is in python-project-templates/base#223.

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
@timkpaine timkpaine added the tag: automerge Automatically merge this PR when status checks pass label Nov 14, 2026
@python-templates-automerge
python-templates-automerge Bot merged commit 1f35eaa into main Nov 14, 2026
16 checks passed
@python-templates-automerge
python-templates-automerge Bot deleted the enable-c-abi-library branch November 14, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tag: automerge Automatically merge this PR when status checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant