diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-09-11 18:47:58 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-09-12 11:30:24 +0000 |
commit | b80eafbd0a60658c7418c3a3537d4ac4f565d112 (patch) | |
tree | 16397a62b49e1e99ece7dd845c15220018b63fef | |
parent | 0dd71b40f6c86a8cf1d3ff442edfe9a6db13379f (diff) |
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 <Friedemann.Kleint@qt.io>
-rw-r--r-- | plugins/pythonextensions/pyutil.cpp | 6 |
1 files 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, ""); } |