Skip to content

[feat/precompile-pybind11-h] feat: expose the precompiled-mode sources to non-CMake builds - #6137

Open
henryiii wants to merge 1 commit into
feat/precompile-pybind11-hfrom
feat/precompile-tooling
Open

[feat/precompile-pybind11-h] feat: expose the precompiled-mode sources to non-CMake builds#6137
henryiii wants to merge 1 commit into
feat/precompile-pybind11-hfrom
feat/precompile-tooling

Conversation

@henryiii

@henryiii henryiii commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

🤖 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() and python -m pybind11 --srcdir locate the shipped src/ directory (installed package or repo checkout), mirroring get_include().
  • pybind11.pc gains a srcdir= variable.
  • Pybind11Extension(..., precompile=True) appends src/pybind11_combined.cpp (single-TU amalgam) to the extension sources and defines PYBIND11_PRECOMPILED. A missing source tree is a hard error rather than a silent header-only fallback; the standalone-copied setup_helpers.py continues to work when the kwarg is not used. Each extension compiles its own copy (no cross-extension sharing), which keeps per-module state semantics.
  • New test_precompile_setup_py in tests/extra_setuptools/.

Meson users: dependency('pybind11').get_variable('srcdir') + -DPYBIND11_PRECOMPILED — a documentation snippet lands in the docs PR.

Suggested changelog entry:

  • Placeholder.

📚 Documentation preview 📚: https://pybind11--6137.org.readthedocs.build/

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
henryiii force-pushed the feat/precompile-tooling branch from ebed7aa to 1cf3e84 Compare August 7, 2026 12:41
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.

1 participant