Skip to content

Commit

Permalink
fix: 🐛 properly escape paths
Browse files Browse the repository at this point in the history
Handle spaces in paths

Partially address #73
  • Loading branch information
melMass committed Aug 25, 2023
1 parent bb35098 commit 22cac9b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
from contextlib import suppress
from queue import Queue, Empty
from contextlib import contextmanager
import shlex

here = Path(__file__).parent
executable = sys.executable
executable = Path(sys.executable)

# - detect mode
mode = None
Expand Down Expand Up @@ -153,7 +154,7 @@ def run_command(cmd, ignored_lines_start=None):
for arg in cmd:
if isinstance(arg, Path):
arg = arg.as_posix()
shell_cmd += f"{arg} "
shell_cmd += f"{shlex.quote(str(arg))} "
else:
raise ValueError(
"Invalid 'cmd' argument. It must be a string or a list of arguments."
Expand Down Expand Up @@ -237,7 +238,7 @@ def signal_handler(signum, frame):
import requirements
except ImportError:
print_formatted("Installing requirements-parser...", "italic", color="yellow")
run_command([sys.executable, "-m", "pip", "install", "requirements-parser"])
run_command([executable, "-m", "pip", "install", "requirements-parser"])
import requirements

print_formatted("Done.", "italic", color="green")
Expand All @@ -246,7 +247,7 @@ def signal_handler(signum, frame):
from tqdm import tqdm
except ImportError:
print_formatted("Installing tqdm...", "italic", color="yellow")
run_command([sys.executable, "-m", "pip", "install", "--upgrade", "tqdm"])
run_command([executable, "-m", "pip", "install", "--upgrade", "tqdm"])
from tqdm import tqdm

pip_map = {
Expand Down Expand Up @@ -390,7 +391,7 @@ def import_or_install(requirement, dry=False):
)
else:
try:
run_command([sys.executable, "-m", "pip", "install", pip_install_name])
run_command([executable, "-m", "pip", "install", pip_install_name])
print_formatted(
f"Package {pip_install_name} installed successfully using pip package name (import name: '{import_name}')",
"bold",
Expand Down Expand Up @@ -611,7 +612,7 @@ def install_dependencies(dry=False):
# # check if installed
# missing_deps_urls.append(whl_file["browser_download_url"])

install_cmd = [sys.executable, "-m", "pip", "install"]
install_cmd = [executable, "-m", "pip", "install"]

# - Install all deps
if not args.dry:
Expand Down

0 comments on commit 22cac9b

Please sign in to comment.