[feat/precompile-pybind11-h] feat: expose the precompiled-mode sources to non-CMake builds - #6137
Open
henryiii wants to merge 1 commit into
Open
[feat/precompile-pybind11-h] feat: expose the precompiled-mode sources to non-CMake builds#6137henryiii wants to merge 1 commit into
henryiii wants to merge 1 commit into
Conversation
henryiii
force-pushed
the
feat/precompile-tooling
branch
from
August 7, 2026 03:25
d355af3 to
9b2f2fa
Compare
henryiii
force-pushed
the
feat/precompile-tooling
branch
from
August 7, 2026 03:27
9b2f2fa to
66f3f6d
Compare
henryiii
force-pushed
the
feat/precompile-tooling
branch
from
August 7, 2026 03:33
66f3f6d to
ebed7aa
Compare
Adds pybind11.get_source_dir() / python -m pybind11 --srcdir, a srcdir variable in pybind11.pc, and Pybind11Extension(precompile=True) which compiles src/pybind11_combined.cpp into the extension and defines PYBIND11_PRECOMPILED (hard error if the sources are missing). Assisted-by: ClaudeCode:claude-fable-5
henryiii
force-pushed
the
feat/precompile-tooling
branch
from
August 7, 2026 12:41
ebed7aa to
1cf3e84
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Description
Stacked on #6136. Gives every non-CMake build system a simple way to use the precompiled mode:
pybind11.get_source_dir()andpython -m pybind11 --srcdirlocate the shippedsrc/directory (installed package or repo checkout), mirroringget_include().pybind11.pcgains asrcdir=variable.Pybind11Extension(..., precompile=True)appendssrc/pybind11_combined.cpp(single-TU amalgam) to the extension sources and definesPYBIND11_PRECOMPILED. A missing source tree is a hard error rather than a silent header-only fallback; the standalone-copiedsetup_helpers.pycontinues to work when the kwarg is not used. Each extension compiles its own copy (no cross-extension sharing), which keeps per-module state semantics.test_precompile_setup_pyintests/extra_setuptools/.Meson users:
dependency('pybind11').get_variable('srcdir')+-DPYBIND11_PRECOMPILED— a documentation snippet lands in the docs PR.Suggested changelog entry:
📚 Documentation preview 📚: https://pybind11--6137.org.readthedocs.build/