[zorg] r324138 - The --format flag is only in pip 9 and later
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 13:24:00 PST 2018
Author: cmatthews
Date: Fri Feb 2 13:24:00 2018
New Revision: 324138
URL: http://llvm.org/viewvc/llvm-project?rev=324138&view=rev
Log:
The --format flag is only in pip 9 and later
So lets make that an implicit dependency.
Modified:
zorg/trunk/dep/dep.py
zorg/trunk/dep/tests/test_dep.py
Modified: zorg/trunk/dep/dep.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/dep/dep.py?rev=324138&r1=324137&r2=324138&view=diff
==============================================================================
--- zorg/trunk/dep/dep.py (original)
+++ zorg/trunk/dep/dep.py Fri Feb 2 13:24:00 2018
@@ -539,7 +539,16 @@ class Pip(Dependency):
def verify(self):
"""Verify the packages in pip match this dependency."""
+
try:
+ pip_version = subprocess.check_output(["/usr/bin/env", "python", "-m", "pip", "--version"])
+ pip_tokens = pip_version.split()
+ assert pip_tokens[0] == "pip"
+ pip_version = Version(pip_tokens[1])
+
+ if pip_version < Version("9.0.0"):
+ raise MissingDependencyError("Version of pip too old.")
+
pip_package_config = json.loads(subprocess.check_output(["/usr/bin/env",
"python", "-m", "pip", "list", "--format=json"]))
except (subprocess.CalledProcessError, OSError):
Modified: zorg/trunk/dep/tests/test_dep.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/dep/tests/test_dep.py?rev=324138&r1=324137&r2=324138&view=diff
==============================================================================
--- zorg/trunk/dep/tests/test_dep.py (original)
+++ zorg/trunk/dep/tests/test_dep.py Fri Feb 2 13:24:00 2018
@@ -237,8 +237,18 @@ def test_pip_requirement(mocker):
assert b.command == "pip"
assert b.package == "pytest"
assert b.version_text == "3.3.1"
+
+ # Check an old version of pip raises a dependency error.
+ mocker.patch('dep.subprocess.check_output')
+ dep.subprocess.check_output.side_effect = ["pip 1.2.3 from /Python/pip-1.3.1-py2.7.egg (python 2.7)",
+ open(here + '/assets/pip_output.json').read()]
+ with pytest.raises(MissingDependencyError):
+ b.verify_and_act()
+
+ num_of_checks = 4
mocker.patch('dep.subprocess.check_output')
- dep.subprocess.check_output.return_value = open(here + '/assets/pip_output.json').read()
+ dep.subprocess.check_output.side_effect = ["pip 9.0.1 from /Python/pip-1.3.1-py2.7.egg (python 2.7)",
+ open(here + '/assets/pip_output.json').read()] * num_of_checks
b.verify_and_act()
assert dep.subprocess.check_output.called
More information about the llvm-commits
mailing list