Skip to content

[BUG]: pybind11-config --includes does not quote paths #5300

@QuLogic

Description

@QuLogic

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.13.1

Problem description

On a Windows VM, I installed Python (from python.org) globally for external reasons; this resulted in an install to C:\Program Files\Python312. Since pybind11-config --includes adds sysconfig.get_path("include") and sysconfig.get_path("platinclude"), the result includes that system path as well.

Because these paths contain spaces, and the paths are not quoted, they can be interpreted as multiple arguments. I have not tried the CMake integration, but at least with Meson, they are split into separate -IC:\Program and Files\Python312\Include. For example, a build of Matplotlib outputs:

[95/101] "cl" "-Isrc\_ttconv.cp312-win_amd64.pyd.p" "-Isrc" "-I..\..\src" "-Iextern\ttconv" "-I..\..\extern\ttconv" "-IC:\Program" "-Ic:\Users\Elliott\matplotlib\venv\Lib\site-packages\pybind11\include" "-IC:\Program Files\Python312\Include" "-DNDEBUG" "/MT" "/nologo" "/showIncludes" "/utf-8" "/Zc:__cplusplus" "/W2" "/EHsc" "/std:c++17" "/permissive-" "/O2" "/Gw" "Files\Python312\Include" "/d2FH4-" "-DPY_ARRAY_UNIQUE_SYMBOL=MPL__ttconv_ARRAY_API" "/Fdsrc\_ttconv.cp312-win_amd64.pyd.p\_ttconv.cpp.pdb" /Fosrc/_ttconv.cp312-win_amd64.pyd.p/_ttconv.cpp.obj "/c" ../../src/_ttconv.cpp

Magically, this just happens to work because the right include path was added for other reasons, and MSVC ignores the broken one:

cl : Command line warning D9024 : unrecognized source file type 'Files\Python312\Include', object file assumed
cl : Command line warning D9027 : source file 'Files\Python312\Include' ignored

but if it were to become more strict, it might break.

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions