Uh oh!
There was an error while loading. Please reload this page.
fix: escape paths with spaces in pybind11-config - #4874
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'd forgotten about this. Unless mslex modernizes a bit (it currently uses setup.py with deprecated arguments, like test_requires), I think I'd like to just have the custom form (like meson). I think we can go a bit simpler, though, since double quotes are not valid in a Windows path, only single quotes are. I'll update this. |
4099e56 to
95b1bedCompareSigned-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
rwgk
left a comment
There was a problem hiding this comment.
... alright ...
I cannot honestly write "looks good to me" here, but it seem beyond anyone's capacity (definitely my own) to do something actually good here :-)
I'm holding out hope that some future Python version will come with a platform-aware rock-solid quote() implementation out of the box.
QuLogic
commented
Aug 14, 2024
FWIW, I just tried this on Windows, and everything is quoted enough to work properly, and |
* fix: Escape paths with spaces in include list from --includes * fix: --includes should not use shlex on Windows platforms * Apply suggestions from code review * fix: use custom impl Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Support trailing backslashes Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Markus Bauer <markus.bauer@cispa.saarland> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
henryiii
commented
Aug 15, 2024
Released. |
Description
tl;dr:
pybind11 --includesreturns invalid arguments when the project's directory contains spaces.When you build an extension manually, the docs suggest this command:
c++ ... $(python3 -m pybind11 --includes) ....However, this command fails when the project's directory contains a space in its path.
The command would then expand to
c++ ... -I/home/user/a b/c -I/python ..., where/home/user/ais a in invalid include directory, andb/cis an invalid compiler argument.Even if no manual build is desired this bug might affect users: for example, we're currently building
clang-tidyin our project, which requires all include paths.To solve this issue, this PR escapes include paths of
pybind11 --includesbefore printing. Paths without spaces/special characters are printed as-is, while paths with spaces are wrapped in''. Thus, the final command line of custom builds will be valid even if spaces occur:c++ ... '-I/home/user/a b/c' -I/python ...Suggested changelog entry: