Showing with 37 additions and 5 deletions.
  1. +5 −1 .gitignore
  2. +1 −1 Modulefile
  3. +31 −3 manifests/pip.pp
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
pkg/
pkg/

# ignore rbvenv files used for puppet-lint, rspect etc.
.ruby-version
.rbenv-gemsets
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'stankevich-python'
version '1.7.2'
version '1.7.3'

author 'Sergey Stankevich'
license 'Apache License, Version 2.0'
Expand Down
34 changes: 31 additions & 3 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@
# [*proxy*]
# Proxy server to use for outbound connections. Default: none
#
# [*editable*]
# Boolean. If true the package is installed as an editable resource.
#
# [*environment*]
# Additional environment variables required to install the packages. Default: none
#
# [*install_args*]
# String. Any additional installation arguments that will be supplied
# when running pip install.
#
# [*uninstall args*]
# String. Any additional arguments that will be supplied when running
# pip uninstall.
#
# === Examples
#
# python::pip { 'flask':
Expand All @@ -48,6 +59,7 @@
$owner = 'root',
$proxy = false,
$egg = false,
$editable = false,
$environment = [],
$install_args = '',
$uninstall_args = '',
Expand Down Expand Up @@ -77,6 +89,22 @@
default => "--proxy=${proxy}",
}

if $editable == true {
$install_editable = ' -e '
}
else {
$install_editable = ''
}

#TODO: Do more robust argument checking, but below is a start
if ($ensure == absent) and ($install_args != '') {
fail('python::pip cannot provide install_args with ensure => absent')
}

if $(ensure == present) and ($uninstall_args != '') {
fail('python::pip cannot provide uninstall_args with ensure => present')
}

# Check if searching by explicit version.
if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ {
$grep_regex = "^${pkgname}==${ensure}\$"
Expand Down Expand Up @@ -117,7 +145,7 @@
# Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes
# Explicit version.
exec { "pip_install_${name}":
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}==${ensure}",
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure}",
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
environment => $environment,
Expand All @@ -128,7 +156,7 @@
present: {
# Whatever version is available.
exec { "pip_install_${name}":
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}",
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}",
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
environment => $environment,
Expand All @@ -139,7 +167,7 @@
latest: {
# Latest version.
exec { "pip_install_${name}":
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}",
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${uninstall_args} ${install_editable} ${source}",
unless => "${pip_env} search ${source} | grep -i INSTALLED | grep -i latest",
user => $owner,
environment => $environment,
Expand Down