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
=== modified file 'charmhelpers/contrib/python/packages.py'
--- charmhelpers/contrib/python/packages.py 2015-06-24 18:47:47 +0000
+++ charmhelpers/contrib/python/packages.py 2015-11-03 19:41:19 +0000
@@ -42,8 +42,12 @@
42 yield "--{0}={1}".format(key, value)42 yield "--{0}={1}".format(key, value)
4343
4444
45def pip_install_requirements(requirements, **options):45def pip_install_requirements(requirements, constraints=None, **options):
46 """Install a requirements file """46 """Install a requirements file.
47
48 :param constraints: Path to pip constraints file.
49 http://pip.readthedocs.org/en/stable/user_guide/#constraints-files
50 """
47 command = ["install"]51 command = ["install"]
4852
49 available_options = ('proxy', 'src', 'log', )53 available_options = ('proxy', 'src', 'log', )
@@ -51,8 +55,13 @@
51 command.append(option)55 command.append(option)
5256
53 command.append("-r {0}".format(requirements))57 command.append("-r {0}".format(requirements))
54 log("Installing from file: {} with options: {}".format(requirements,58 if constraints:
55 command))59 command.append("-c {0}".format(constraints))
60 log("Installing from file: {} with constraints {} "
61 "and options: {}".format(requirements, constraints, command))
62 else:
63 log("Installing from file: {} with options: {}".format(requirements,
64 command))
56 pip_execute(command)65 pip_execute(command)
5766
5867
5968
=== modified file 'tests/contrib/python/test_packages.py'
--- tests/contrib/python/test_packages.py 2015-05-06 15:51:25 +0000
+++ tests/contrib/python/test_packages.py 2015-11-03 19:41:19 +0000
@@ -44,6 +44,12 @@
44 "-r test_requirements.txt"])44 "-r test_requirements.txt"])
4545
46 packages.pip_install_requirements("test_requirements.txt",46 packages.pip_install_requirements("test_requirements.txt",
47 "test_constraints.txt")
48 self.pip_execute.assert_called_with(["install",
49 "-r test_requirements.txt",
50 "-c test_constraints.txt"])
51
52 packages.pip_install_requirements("test_requirements.txt",
47 proxy="proxy_addr:8080")53 proxy="proxy_addr:8080")
4854
49 self.pip_execute.assert_called_with(["install",55 self.pip_execute.assert_called_with(["install",

Subscribers

People subscribed via source and target branches