diff options
author | Antonis Christofides <antonis@wikical.com> | 2013-10-08 17:59:17 +0300 |
---|---|---|
committer | Antonis Christofides <antonis@wikical.com> | 2013-10-08 17:59:17 +0300 |
commit | 4f2c04b70452249e6917859fdbf02bd90ec3af79 (patch) | |
tree | d9d18f6f9b7932fe6ad8fb72aee72764883b3648 | |
parent | a017bd325e677159e37d22d5b2ef65377846b23e (diff) |
Added src parameter for pip in python::requirements
A requirements file can have --editable resources; in such a case the
pip default is to install them in ~/src/, which can be unsuitable; for
example, if run by root, /root/src/ is usually unreadable by other
users. pip provides an --src parameter to specify an alternative
directory. This is useful for installing requirements systemwide,
outside a virtualenv.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | manifests/requirements.pp | 13 |
2 files changed, 14 insertions, 1 deletions
@@ -77,6 +77,8 @@ Installs and manages Python packages from requirements file. **owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root +**src** - The ``--src`` parameter to ``pip``, used to specify where to install ``--editable`` resources; by default no ``--src`` parameter is passed to ``pip``. + **group** - The group that was used to create the virtualenv. This is used to create the requirements file with correct permissions if it's not present already. python::requirements { '/var/www/project1/requirements.txt': diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 67906fc..60c5b6c 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -19,6 +19,11 @@ # [*proxy*] # Proxy server to use for outbound connections. Default: none # +# [*src*] +# Pip --src parameter; if the requirements file contains --editable resources, +# this parameter specifies where they will be installed. See the pip +# documentation for more. Default: none (i.e. use the pip default). +# # [*environment*] # Additional environment variables required to install the packages. Default: none # @@ -41,6 +46,7 @@ define python::requirements ( $owner = 'root', $group = 'root', $proxy = false, + $src = false, $environment = [] ) { @@ -63,6 +69,11 @@ define python::requirements ( default => "--proxy=${proxy}", } + $src_flag = $src ? { + false => '', + default => "--src=${src}", + } + # This will ensure multiple python::virtualenv definitions can share the # the same requirements file. if !defined(File[$requirements]) { @@ -79,7 +90,7 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} -r ${requirements}", + command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", refreshonly => true, timeout => 1800, user => $owner, |