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/

@henryiii
henryiii force-pushed the feat/precompile-tooling branch from d355af3 to 9b2f2fa Compare August 7, 2026 03:25
@henryiii
henryiii force-pushed the feat/precompile-tooling branch from 9b2f2fa to 66f3f6d Compare August 7, 2026 03:27
@henryiii
henryiii force-pushed the feat/precompile-tooling branch from 66f3f6d to ebed7aa Compare August 7, 2026 03:33
@henryiii
henryiii force-pushed the feat/precompile-tooling branch 2 times, most recently from 1cf3e84 to bbcdcf6 Compare August 7, 2026 16:27
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 bbcdcf6 to 80852b2 Compare August 8, 2026 01:14
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