Skip to content

Commit

Permalink
Merge pull request #870 from daltonmaag/dirs-with-spaces
Browse files Browse the repository at this point in the history
Support project directories with spaces
  • Loading branch information
m4rc1e authored Mar 21, 2024
2 parents 7e5b3f8 + f9735df commit 9d20701
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Lib/gftools/builder/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tempfile import NamedTemporaryFile

from gftools.builder.file import File
from gftools.utils import shell_quote


@dataclass
Expand Down Expand Up @@ -52,7 +53,7 @@ def write_rules(cls, writer):
cmd = cls.rule + " $stamp"
writer.rule(
name,
sys.executable + " -m gftools.builder.jobrunner " + cmd,
f"{shell_quote(sys.executable)} -m gftools.builder.jobrunner {cmd}",
description=name,
)
writer.newline()
Expand Down
15 changes: 15 additions & 0 deletions Lib/gftools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
from __future__ import annotations
from typing import Union
import requests
from io import BytesIO
from zipfile import ZipFile
Expand All @@ -31,6 +32,8 @@
import json
from PIL import Image
import re
import shlex
import subprocess
from fontTools import unicodedata as ftunicodedata
from fontTools.ttLib import TTFont
from ufo2ft.util import classifyGlyphs
Expand Down Expand Up @@ -601,3 +604,15 @@ def open_ufo(path):
else: # Maybe a .ufoz
return ufoLib2.Font.open(path)
return False

# https://github.com/googlefonts/nanoemoji/blob/fb4b0b3e10f7197e7fe33c4ae6949841e4440397/src/nanoemoji/util.py#L167-L176
def shell_quote(s: Union[str, Path]) -> str:
"""Quote a string or pathlib.Path for use in a shell command."""
s = str(s)
# shlex.quote() is POSIX-only, for Windows we use subprocess.list2cmdline()
# which converts a list of args to a command line string following the
# the MS C runtime rules.
if sys.platform.startswith("win"):
return subprocess.list2cmdline([s])
else:
return shlex.quote(s)

0 comments on commit 9d20701

Please sign in to comment.