Skip to content

Commit

Permalink
fix: --includes should not use shlex on Windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Bauer authored and henryiii committed Aug 14, 2024
1 parent a0fdf01 commit 4c9413a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions pybind11/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@
from __future__ import annotations

import argparse
import shlex
import sys
import sysconfig

from ._version import __version__
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir

try:
from oslex import quote
except ImportError:
import os

if os.name != "nt":
from shlex import quote
else:
# minimal attempt, handling only the most common case (spaces in path)
def quote(s: str) -> str:
return '"' + s + '"' if " " in s else s


def print_includes() -> None:
dirs = [
Expand All @@ -23,7 +34,7 @@ def print_includes() -> None:
if d and d not in unique_dirs:
unique_dirs.append(d)

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


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true

[[tool.mypy.overrides]]
module = ["ghapi.*"]
module = ["ghapi.*", "oslex"]
ignore_missing_imports = true


Expand Down

0 comments on commit 4c9413a

Please sign in to comment.