Showing with 27 additions and 32 deletions.
  1. +1 −1 Modulefile
  2. +8 −14 manifests/pip.pp
  3. +18 −17 manifests/virtualenv.pp
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.1'
version '1.7.2'

author 'Sergey Stankevich'
license 'Apache License, Version 2.0'
Expand Down
22 changes: 8 additions & 14 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# must be unique
#
# [*pkgname]
# name of the package.
# name of the package. If pkgname is not specified, use name (title) instead.
#
# [*ensure*]
# present|absent. Default: present
Expand Down Expand Up @@ -41,7 +41,7 @@
# Fotis Gimian
#
define python::pip (
$pkgname = undef,
$pkgname = $name,
$ensure = present,
$virtualenv = 'system',
$url = false,
Expand Down Expand Up @@ -77,29 +77,23 @@
default => "--proxy=${proxy}",
}

# If pkgname is not specified, use name (title) instead.
$use_pkgname = $pkgname ? {
undef => $name,
default => $pkgname
}

# 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 = "^${use_pkgname}==${ensure}\$"
$grep_regex = "^${pkgname}==${ensure}\$"
} else {
$grep_regex = $use_pkgname ? {
/==/ => "^${use_pkgname}\$",
default => "^${use_pkgname}==",
$grep_regex = $pkgname ? {
/==/ => "^${pkgname}\$",
default => "^${pkgname}==",
}
}

$egg_name = $egg ? {
false => $use_pkgname,
false => $pkgname,
default => $egg
}

$source = $url ? {
false => $use_pkgname,
false => $pkgname,
default => "${url}#egg=${egg_name}",
}

Expand Down
35 changes: 18 additions & 17 deletions manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# [*systempkgs*]
# Copy system site-packages into virtualenv. Default: don't
# If virtualenv version < 1.7 this flag has no effect since
# the system packages were not supported
# [*venv_dir*]
# Directory to install virtualenv to. Default: $name
#
# [*distribute*]
# Include distribute in the virtualenv. Default: true
Expand Down Expand Up @@ -64,23 +65,22 @@
# Fotis Gimian
#
define python::virtualenv (
$ensure = present,
$version = 'system',
$requirements = false,
$systempkgs = false,
$distribute = true,
$index = false,
$owner = 'root',
$group = 'root',
$proxy = false,
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ],
$cwd = undef,
$timeout = 1800
$ensure = present,
$version = 'system',
$requirements = false,
$systempkgs = false,
$venv_dir = $name,
$distribute = true,
$index = false,
$owner = 'root',
$group = 'root',
$proxy = false,
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin' ],
$cwd = undef,
$timeout = 1800
) {

$venv_dir = $name

if $ensure == 'present' {

$python = $version ? {
Expand Down Expand Up @@ -130,8 +130,9 @@
exec { "python_virtualenv_${venv_dir}":
command => "mkdir -p ${venv_dir} ${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,
creates => "${venv_dir}/bin/activate",
path => $path,
cwd => "/tmp",
cwd => '/tmp',
environment => $environment,
unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv
}
Expand Down