Skip to content

Commit

Permalink
Merge pull request #114 from neilkatin/patch-for-ticket-66
Browse files Browse the repository at this point in the history
Proposed fix for ticket 66: allow extra arguments when using requirement...
  • Loading branch information
shivapoudel committed Aug 13, 2014
2 parents 13fff84 + 79c2b0e commit 4c4c9ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
# [*cwd*]
# The directory from which to run the "pip install" command. Default: undef
#
# [*extra_pip_args*]
# Extra arguments to pass to pip after the requirements file
#
# === Examples
#
# python::requirements { '/var/www/project1/requirements.txt':
Expand All @@ -58,6 +61,7 @@
$environment = [],
$forceupdate = false,
$cwd = undef,
$extra_pip_args = '',
) {

if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') {
Expand Down Expand Up @@ -100,7 +104,7 @@

exec { "python_requirements${name}":
provider => shell,
command => "${pip_env} --log ${rootdir}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}",
command => "${pip_env} --log ${rootdir}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements} $extra_pip_args",
refreshonly => !$forceupdate,
timeout => 1800,
cwd => $cwd,
Expand Down
11 changes: 9 additions & 2 deletions manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# [*timeout*]
# The maximum time in seconds the "pip install" command should take. Default: 1800
#
# [*extra_pip_args*]
# Extra arguments to pass to pip after requirements file. Default: blank
#
# === Examples
#
# python::virtualenv { '/var/www/project1':
Expand Down Expand Up @@ -78,7 +81,8 @@
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin' ],
$cwd = undef,
$timeout = 1800
$timeout = 1800,
$extra_pip_args = ''
) {

if $ensure == 'present' {
Expand Down Expand Up @@ -137,6 +141,8 @@
group => $group,
}



exec { "python_virtualenv_${venv_dir}":
command => "true ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg} || ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg} ;}",
user => $owner,
Expand All @@ -150,7 +156,7 @@

if $requirements {
exec { "python_requirements_initial_install_${requirements}_${venv_dir}":
command => "${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag -r ${requirements}",
command => "${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag -r ${requirements} $extra_pip_args",
refreshonly => true,
timeout => $timeout,
user => $owner,
Expand All @@ -167,6 +173,7 @@
group => $group,
cwd => $cwd,
require => Exec["python_virtualenv_${venv_dir}"],
extra_pip_args => $extra_pip_args,
}
}
} elsif $ensure == 'absent' {
Expand Down

0 comments on commit 4c4c9ed

Please sign in to comment.