From 2865f4fb87ea7e5831ed497ddb90999f83913b7e Mon Sep 17 00:00:00 2001 From: wimh Date: Fri, 18 Jul 2014 18:46:27 +0200 Subject: allow to specify directory from which to run the "pip install" command --- manifests/requirements.pp | 9 +++++++-- manifests/virtualenv.pp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 11c5f00..2373337 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -32,6 +32,9 @@ # requirements file - Useful for when the requirements file is written as part of a # resource other than file (E.g vcsrepo) # +# [*cwd*] +# The directory from which to run the "pip install" command. Default: undef +# # === Examples # # python::requirements { '/var/www/project1/requirements.txt': @@ -54,13 +57,14 @@ define python::requirements ( $src = false, $environment = [], $forceupdate = false, + $cwd = undef, ) { if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { fail('python::pip: root user must be used when virtualenv is system') } - $cwd = $virtualenv ? { + $rootdir = $virtualenv ? { 'system' => '/', default => $virtualenv, } @@ -96,9 +100,10 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", + command => "${pip_env} --log ${rootdir}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", refreshonly => !$forceupdate, timeout => 1800, + cwd => $cwd, user => $owner, subscribe => File[$requirements], environment => $environment, diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 419e2ae..769c5a8 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -154,6 +154,7 @@ define python::virtualenv ( proxy => $proxy, owner => $owner, group => $group, + cwd => $cwd, require => Exec["python_virtualenv_${venv_dir}"], } } -- cgit v1.2.3