Skip to content

Use better qualified name for cpython extension module shared library#113

Merged
timkpaine merged 4 commits into
python-project-templates:mainfrom
anlambert:main
Jul 2, 2026
Merged

Use better qualified name for cpython extension module shared library#113
timkpaine merged 4 commits into
python-project-templates:mainfrom
anlambert:main

Conversation

@anlambert

Copy link
Copy Markdown
Contributor

Shared library for a cpython extension module should be suffixed by
the value of the EXT_SUFFIX configuration variable from the sysconfig
module.

Fixes #24.

anlambert added 2 commits July 2, 2026 15:14
Some vcpkg ports have some Python tests files that should not be
collected by pytest.
CMake Python module defines a python_add_library command to easily
compile a cpython extension module.
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.20%. Comparing base (924c143) to head (b9165b7).

Files with missing lines Patch % Lines
hatch_cpp/tests/test_projects.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
+ Coverage   87.71%   94.20%   +6.48%     
==========================================
  Files          14       14              
  Lines        1180     1190      +10     
==========================================
+ Hits         1035     1121      +86     
+ Misses        145       69      -76     

☔ 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.

Shared library for a cpython extension module should be suffixed by
the value of the EXT_SUFFIX configuration variable from the sysconfig
module.

Fixes python-project-templates#24.
@anlambert

Copy link
Copy Markdown
Contributor Author

Codecov report seems wrong as this what i get when testing locally:

Name                                                                  Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------------------------------
hatch_cpp/__init__.py                                                     5      0   100%
hatch_cpp/config.py                                                      84     21    75%   47-48, 50, 53, 75, 77, 80, 94-100, 110-114, 117-119
hatch_cpp/hooks.py                                                        6      1    83%   10
hatch_cpp/plugin.py                                                      69     55    20%   26-113
hatch_cpp/tests/test_hatch_build.py                                      22      2    91%   34, 37
hatch_cpp/tests/test_platform_specific.py                               225      0   100%
hatch_cpp/tests/test_project_basic/project/__init__.py                    0      0   100%
hatch_cpp/tests/test_project_cmake/project/__init__.py                    0      0   100%
hatch_cpp/tests/test_project_cmake_vcpkg/project/__init__.py              0      0   100%
hatch_cpp/tests/test_project_hatch_build/project/__init__.py              0      0   100%
hatch_cpp/tests/test_project_limited_api/project/__init__.py              0      0   100%
hatch_cpp/tests/test_project_nanobind/project/__init__.py                 0      0   100%
hatch_cpp/tests/test_project_override_classes/project/__init__.py         0      0   100%
hatch_cpp/tests/test_project_override_toolchain/project/__init__.py       0      0   100%
hatch_cpp/tests/test_project_pybind/project/__init__.py                   0      0   100%
hatch_cpp/tests/test_project_pybind_vcpkg/project/__init__.py             0      0   100%
hatch_cpp/tests/test_projects.py                                         30      1    97%   57
hatch_cpp/tests/test_structs.py                                         151      1    99%   51
hatch_cpp/tests/test_vcpkg_ref.py                                       143      0   100%
hatch_cpp/toolchains/__init__.py                                          3      0   100%
hatch_cpp/toolchains/cmake.py                                            54      6    89%   52, 60-62, 80, 84
hatch_cpp/toolchains/common.py                                          311     48    85%   105-106, 114, 122, 251-263, 278-282, 307-311, 313-319, 323, 334, 336-342, 353-354, 378, 380, 382, 393, 395, 414-415
hatch_cpp/toolchains/vcpkg.py                                            80     11    86%   87, 92, 96-103, 121
hatch_cpp/utils.py                                                        7      1    86%   12
---------------------------------------------------------------------------------------------------
TOTAL                                                                  1190    147    88%
Coverage XML written to file coverage.xml
Required test coverage of 50.0% reached. Total coverage: 87.65%

@anlambert

Copy link
Copy Markdown
Contributor Author

I do not get why my changes in hatch_cpp/toolchains/common.py appear not covered in coverage report while they are (I double checked by adding some debug print).

I also get the same locally when displaying coverage report in VS code.

@anlambert

Copy link
Copy Markdown
Contributor Author

I do not get why my changes in hatch_cpp/toolchains/common.py appear not covered in coverage report while they are (I double checked by adding some debug print).

I also get the same locally when displaying coverage report in VS code.

Ah I see, the code is executed by subprocess.check_call in the test so pytest-cov cannot track the coverage in that case.

@anlambert

Copy link
Copy Markdown
Contributor Author

Ah I see, the code is executed by subprocess.check_call in the test so pytest-cov cannot track the coverage in that case.

But this can be fixed by enabling subprocess support in pytest-cov.

I pushed a new commit with that fix.

@timkpaine timkpaine merged commit 86a6121 into python-project-templates:main Jul 2, 2026
5 checks passed
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.

Add better qualified names for python shared libraries

2 participants