Skip to content

[python] Anchor the cpyrt header probe on the extension module - #25

Open
aaronj0 wants to merge 1 commit into
mainfrom
editable-cpyrt-probe
Open

[python] Anchor the cpyrt header probe on the extension module#25
aaronj0 wants to merge 1 commit into
mainfrom
editable-cpyrt-probe

Conversation

@aaronj0

@aaronj0 aaronj0 commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

In editable installs the cpyrt header probe checked __file__, which maps to the source tree, so it missed the headers installed by scikit-build-core into site-packages and warned on every import. Now use the libcppjit extension's location, which resolves editable and regular installs identically. Also removes all dead lookups inherited with the probe (the cpyrt pip-distribution query via pkg_resources and the site/pythonX.Y layout guesses). CPPJIT_API_PATH still overrides and "none" still disables.

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

Test Results

Configuration Result
macos-26-intel-llvm21-py3.14-cxx20 = 437 passed, 44 skipped, 85 xfailed, 32 xpassed, 100 warnings in 157.75s (0:02:37) =
macos-26-llvm21-py3.14-cxx20 = 438 passed, 37 skipped, 93 xfailed, 30 xpassed, 100 warnings in 63.65s (0:01:03) =
ubuntu-24.04-llvm21-py3.14-cxx20-vg ====== 553 passed, 25 skipped, 18 xfailed, 2 xpassed in 90.67s (0:01:30) =======
ubuntu-24.04-llvm22-py3.14-cxx20 ====== 553 passed, 25 skipped, 19 xfailed, 1 xpassed in 115.09s (0:01:55) ======
ubuntu-24.04-llvm22-py3.14-cxx20-cling ====== 543 passed, 25 skipped, 27 xfailed, 3 xpassed in 85.09s (0:01:25) =======
ubuntu-24.04-llvm22-py3.14-cxx23 ====== 574 passed, 3 skipped, 20 xfailed, 1 xpassed in 117.32s (0:01:57) =======

Comment thread python/cppjit/__init__.py
apipath_extra = os.path.join(
os.path.dirname(_spec.origin), "cppjit_backend", "include"
)
del _spec

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
del _spec

Why do we need to explicitly delete here? Wouldn't the GC collect it if it doesn't have any active references?

@aaronj0 aaronj0 Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is in module scope, the GC will only collect _spec once nothing references it, but here the module itself keeps a reference for the process lifetime (the assignment retains it as cppjit._spec), and it shows up in dir(cppjit). The del drops that. We already do del on apipath_extra, include_path, apipath, ispypy for the same reason (also only required at init time and not a part of dir(cppjit))

In editable installs the cpyrt header probe checked `__file__`, which maps
to the source tree, so it missed the headers installed by scikit-build-core
into site-packages and warned on every import. Now use the libcppjit extension's
location, which resolves editable and regular installs identically. Also remove
all dead lookups inherited with the probe (the `cpyrt` pip-distribution query
via pkg_resources and the site/pythonX.Y layout guesses). `CPPJIT_API_PATH` still
overrides and `"none"` still disables.
@aaronj0
aaronj0 force-pushed the editable-cpyrt-probe branch from 8ae9b2e to 9df3efe Compare August 19, 2026 07:33
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.

2 participants