From b80eafbd0a60658c7418c3a3537d4ac4f565d112 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 11 Sep 2018 18:47:58 +0200 Subject: Fix installation of requirements Do not split command lines on whitespace, which destroys arguments with spaces (e.g. the package path inside the Qt Creator app bundle on macOS). Also directly run pip through the module without going through an external python command. Change-Id: I85c8c5d64d21ee0178c43053cb5913f6f3c3b882 Reviewed-by: Friedemann Kleint --- plugins/pythonextensions/pyutil.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/pythonextensions/pyutil.cpp b/plugins/pythonextensions/pyutil.cpp index 169c8a0..15cb719 100644 --- a/plugins/pythonextensions/pyutil.cpp +++ b/plugins/pythonextensions/pyutil.cpp @@ -264,9 +264,9 @@ bool pipInstallRequirements(const std::string &requirements, const std::string & { // Run a requirements.txt file with pip const std::string s = -"import subprocess, sys\n" -"subprocess.check_call(\"{} -m pip install -t " + target + " -r " + requirements + "\".format(sys.executable).split())\n" -"open(\"" + requirements + "\".replace(\"requirements.txt\",\"requirements.txt.installed\"),\"a\").close()\n"; +"import pip._internal\n" +"if pip._internal.main(['install', '-t', '" + target + "', '-r', '" + requirements + "']) == 0:\n" +" open('" + requirements + "'.replace('requirements.txt', 'requirements.txt.installed'), 'a').close()\n"; return runScriptWithPath(s, ""); } -- cgit v1.2.3