Bug 1460402 - Create a new class to manage pip install r=ahal
☠☠ backed out by 5a8eea8a92bb ☠ ☠
authorSylvestre Ledru <sledru@mozilla.com>
Thu, 10 May 2018 19:05:30 +0200
changeset 417807 3e50885329c49bbd9eeb4f76b98604f49fb50735
parent 417806 b4aafc195b9f9c4cca3c136c98693f3d9d528bf0
child 417808 bb12ffd4b96e318f1e492661efb9747862988c77
push id33980
push userebalazs@mozilla.com
push dateFri, 11 May 2018 09:35:12 +0000
treeherdermozilla-central@8e9a4a323f0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1460402
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1460402 - Create a new class to manage pip install r=ahal MozReview-Commit-ID: JnscCmC4gBt
python/mozlint/mozlint/util/__init__.py
python/mozlint/mozlint/util/pip.py
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/python/mozlint/mozlint/util/pip.py
@@ -0,0 +1,34 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import subprocess
+
+
+def _run_pip(*args):
+    """
+    Helper function that runs pip with subprocess
+    """
+    try:
+        subprocess.check_output(['pip'] + list(args),
+                                stderr=subprocess.STDOUT)
+        return True
+    except subprocess.CalledProcessError as e:
+        print(e.output)
+        return False
+
+
+def reinstall_program(REQ_PATH):
+    """
+    Try to install flake8 at the target version, returns True on success
+    otherwise prints the otuput of the pip command and returns False
+    """
+    if _run_pip('install', '-U',
+                '--require-hashes', '-r',
+                REQ_PATH):
+        return True
+
+    return False