Merge lp:~blr/charm-helpers/pip-constraints into lp:charm-helpers

Proposed by Kit Randel
Status: Merged
Merged at revision: 498
Proposed branch: lp:~blr/charm-helpers/pip-constraints
Merge into: lp:charm-helpers
Diff against target: 51 lines (+19/-4)
2 files modified
charmhelpers/contrib/python/packages.py (+13/-4)
tests/contrib/python/test_packages.py (+6/-0)
To merge this branch: bzr merge lp:~blr/charm-helpers/pip-constraints
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+276062@code.launchpad.net

Commit message

Add pip constraints support.

Description of the change

Provides support for pip constraints files in contrib.python.packages.pip_install_requirements (http://pip.readthedocs.org/en/stable/user_guide/#constraints-files).

To post a comment you must log in.
477. By Kit Randel

Tidy up docstring.

Revision history for this message
Stuart Bishop (stub) wrote :

This all looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/python/packages.py'
2--- charmhelpers/contrib/python/packages.py 2015-06-24 18:47:47 +0000
3+++ charmhelpers/contrib/python/packages.py 2015-11-03 19:41:19 +0000
4@@ -42,8 +42,12 @@
5 yield "--{0}={1}".format(key, value)
6
7
8-def pip_install_requirements(requirements, **options):
9- """Install a requirements file """
10+def pip_install_requirements(requirements, constraints=None, **options):
11+ """Install a requirements file.
12+
13+ :param constraints: Path to pip constraints file.
14+ http://pip.readthedocs.org/en/stable/user_guide/#constraints-files
15+ """
16 command = ["install"]
17
18 available_options = ('proxy', 'src', 'log', )
19@@ -51,8 +55,13 @@
20 command.append(option)
21
22 command.append("-r {0}".format(requirements))
23- log("Installing from file: {} with options: {}".format(requirements,
24- command))
25+ if constraints:
26+ command.append("-c {0}".format(constraints))
27+ log("Installing from file: {} with constraints {} "
28+ "and options: {}".format(requirements, constraints, command))
29+ else:
30+ log("Installing from file: {} with options: {}".format(requirements,
31+ command))
32 pip_execute(command)
33
34
35
36=== modified file 'tests/contrib/python/test_packages.py'
37--- tests/contrib/python/test_packages.py 2015-05-06 15:51:25 +0000
38+++ tests/contrib/python/test_packages.py 2015-11-03 19:41:19 +0000
39@@ -44,6 +44,12 @@
40 "-r test_requirements.txt"])
41
42 packages.pip_install_requirements("test_requirements.txt",
43+ "test_constraints.txt")
44+ self.pip_execute.assert_called_with(["install",
45+ "-r test_requirements.txt",
46+ "-c test_constraints.txt"])
47+
48+ packages.pip_install_requirements("test_requirements.txt",
49 proxy="proxy_addr:8080")
50
51 self.pip_execute.assert_called_with(["install",

Subscribers

People subscribed via source and target branches