feat: small command line helpers for quick tests#4272
Conversation
2a0be18 to
108e975
Compare
108e975 to
13ec9d9
Compare
|
🤖 AI text below 🤖 Rebased on current master as a single commit. Changes beyond the rebase:
|
Add --cflags, --ldflags, --embed, and --file to the pybind11 command
line tool, based on python-config. This makes quick one-off compiles
easy:
c++ $(python3 -m pybind11 --file=example.cpp)
Assisted-by: ClaudeCode:claude-fable-5
13ec9d9 to
f4afa90
Compare
|
@claude review this PR |
|
Ran manually with Fable medium: 🤖 AI text below 🤖 Review: PR #4272 — feat: small command line helpers for quick testsOverviewAdds Correctness
Code quality / conventions
Tests
Docs
VerdictSolid, useful feature with correct |
- Quote include and library dirs in get_cflags/get_ldflags so paths with spaces work, sharing one quote helper in commands.py - Restructure the --file/--cflags/--ldflags printing into a single print - Note the Unix-compiler orientation in help text and docs - Test -L presence for --embed and quoting of paths with spaces Assisted-by: ClaudeCode:claude-fable-5
- Replace _get_config_var(name, fmt, quote) with a plain _config(name) string helper; formatting and quoting happen at the call sites - Defer sysconfig/shlex imports so import pybind11 does not pay for the CLI (~1ms -> ~0.08ms for pybind11.commands) - Fetch EXT_SUFFIX once in main() - Import commands normally in the quoting test instead of importlib file loading Assisted-by: ClaudeCode:claude-fable-5
|
Also ran 🤖 AI text below 🤖 Done — pushed Fixed:
Skipped, with reasons:
Verified after the changes: |
|
And GPT-5.6-sol: 🤖 AI text below 🤖 The new extension command omits required shared-library flags on Unix platforms other than Linux and macOS, despite claiming general Unix compiler support. Review comment:
|
The --file/--ldflags output only added -shared and -fPIC on Linux, so other Unix platforms (FreeBSD, Solaris, AIX) linked an executable and failed on the missing main. Gate on os.name instead. Assisted-by: ClaudeCode:claude-opus-5
Description
These are some small command line helpers intended for quick testing, based on
python-config.On a Unix system, it should be possible to do:
Or even:
c++ $(pybind11-config --file=pybindclass.cpp)This is handy for quick tests on issue reports.
Since I have to debug embedded code too, I also added support for
--embed:c++ $(pybind11-config --embed --file=pybindclass.cpp)Based on https://github.com/python/cpython/blob/3.11/Misc/python-config.in
Suggested changelog entry:
I can probably come up with a test or two.
📚 Documentation preview 📚: https://pybind11--4272.org.readthedocs.build/