Escape command line requirements as necessary

- Fixes #2998

Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Dan Ryan
2018-10-11 12:35:27 -04:00
parent 485da19d7c
commit 12e80edede
3 changed files with 9 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
Fixed a bug which prevented installing pinned versions which used redirection symbols from the command line.
+2
View File
@@ -40,6 +40,7 @@ from .utils import (
rmtree,
clean_resolved_dep,
parse_indexes,
escape_cmd
)
from . import environments, pep508checker, progress
from .environments import (
@@ -1398,6 +1399,7 @@ def pip_install(
pip_command.append("--upgrade-strategy=only-if-needed")
if no_deps:
pip_command.append("--no-deps")
install_reqs = [escape_cmd(req) for req in install_reqs]
pip_command.extend(install_reqs)
pip_command.extend(prepare_pip_source_args(sources))
if not ignore_hashes:
+6
View File
@@ -1048,6 +1048,12 @@ def handle_remove_readonly(func, path, exc):
raise
def escape_cmd(cmd):
if any(special_char in cmd for special_char in ["<", ">", "&", ".", "^", "|", "?"]):
cmd = '\'{0}\''.format(cmd)
return cmd
@contextmanager
def atomic_open_for_write(target, binary=False, newline=None, encoding=None):
"""Atomically open `target` for writing.