Skip to content

Commit 4c9413a

Browse files
Markus Bauerhenryiii
Markus Bauer
authored andcommitted
fix: --includes should not use shlex on Windows platforms
1 parent a0fdf01 commit 4c9413a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pybind11/__main__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22
from __future__ import annotations
33

44
import argparse
5-
import shlex
65
import sys
76
import sysconfig
87

98
from ._version import __version__
109
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
1110

11+
try:
12+
from oslex import quote
13+
except ImportError:
14+
import os
15+
16+
if os.name != "nt":
17+
from shlex import quote
18+
else:
19+
# minimal attempt, handling only the most common case (spaces in path)
20+
def quote(s: str) -> str:
21+
return '"' + s + '"' if " " in s else s
22+
1223

1324
def print_includes() -> None:
1425
dirs = [
@@ -23,7 +34,7 @@ def print_includes() -> None:
2334
if d and d not in unique_dirs:
2435
unique_dirs.append(d)
2536

26-
print(" ".join(shlex.quote("-I" + d) for d in unique_dirs))
37+
print(" ".join(quote("-I" + d) for d in unique_dirs))
2738

2839

2940
def main() -> None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
2525
warn_unreachable = true
2626

2727
[[tool.mypy.overrides]]
28-
module = ["ghapi.*"]
28+
module = ["ghapi.*", "oslex"]
2929
ignore_missing_imports = true
3030

3131

0 commit comments

Comments
 (0)