From 3c606c95e12be941529fdf86c14f3f35bcddbf69 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Mon, 3 Jun 2013 19:41:24 +1000 Subject: Added owner, group to the pip class which ensures that packages will be installed with the correct permissions. --- manifests/pip.pp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 3a8ec1b..b40b916 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -29,9 +29,11 @@ # define python::pip ( $virtualenv, - $ensure = present, - $url = false, - $proxy = false + $ensure = present, + $url = false, + $owner = 'root', + $group = 'root', + $proxy = false ) { # Parameter validation @@ -57,15 +59,17 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "${virtualenv}/bin/pip install ${proxy_flag} ${source}", - unless => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", + command => "${virtualenv}/bin/pip install ${proxy_flag} ${source}", + unless => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", + user => $owner, } } default: { exec { "pip_uninstall_${name}": - command => "echo y | ${virtualenv}/bin/pip uninstall ${proxy_flag} ${name}", - onlyif => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", + command => "echo y | ${virtualenv}/bin/pip uninstall ${proxy_flag} ${name}", + onlyif => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", + user => $owner, } } } -- cgit v1.2.3 From 5617ad20f4515254d9ac7b9cdef63de59ebece08 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Mon, 3 Jun 2013 19:43:14 +1000 Subject: Added environment attribute to the pip class which allows for users to override environment variables like LD_LIBRARY_PATH and ORACLE_HOME which are needed to install packages like cx_Oracle. --- manifests/pip.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index b40b916..73f4cdc 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -33,7 +33,8 @@ define python::pip ( $url = false, $owner = 'root', $group = 'root', - $proxy = false + $proxy = false, + environment = [] ) { # Parameter validation @@ -62,6 +63,7 @@ define python::pip ( command => "${virtualenv}/bin/pip install ${proxy_flag} ${source}", unless => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", user => $owner, + environment => $environment, } } @@ -70,6 +72,7 @@ define python::pip ( command => "echo y | ${virtualenv}/bin/pip uninstall ${proxy_flag} ${name}", onlyif => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", user => $owner, + environment => $environment, } } } -- cgit v1.2.3 From 1aaef848f4a52d83a6b44eeb4cffd9b61a665c41 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Mon, 3 Jun 2013 23:13:50 +1000 Subject: Made system virtualenv more robust and ensured that pip logging would occur in an appropriate directory upon failure to avoid errors --- manifests/pip.pp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 73f4cdc..0693057 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -28,7 +28,7 @@ # Sergey Stankevich # define python::pip ( - $virtualenv, + $virtualenv = 'system', $ensure = present, $url = false, $owner = 'root', @@ -42,6 +42,20 @@ define python::pip ( fail('python::pip: virtualenv parameter must not be empty') } + if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { + fail('python::pip: root user must be used when virtualenv is system') + } + + $cwd = $virtualenv ? { + 'system' => '/', + default => "${virtualenv}", + } + + $pip_env = $virtualenv ? { + 'system' => '`which pip`', + default => "${virtualenv}/bin/pip", + } + $proxy_flag = $proxy ? { false => '', default => "--proxy=${proxy}", @@ -60,8 +74,8 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "${virtualenv}/bin/pip install ${proxy_flag} ${source}", - unless => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", + command => "$pip_env --log-file ${cwd}/pip.log install ${proxy_flag} ${source}", + unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, } @@ -69,8 +83,8 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | ${virtualenv}/bin/pip uninstall ${proxy_flag} ${name}", - onlyif => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}", + command => "echo y | $pip_env uninstall ${proxy_flag} ${name}", + onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, } -- cgit v1.2.3 From 5132cf1798d862e28f9c9355a2e01a96f585f28f Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Mon, 3 Jun 2013 23:29:44 +1000 Subject: Removed owner attribute from the pip class as it was not needed and touched up a few mistakes. --- manifests/pip.pp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 0693057..3940374 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -28,13 +28,12 @@ # Sergey Stankevich # define python::pip ( - $virtualenv = 'system', - $ensure = present, - $url = false, - $owner = 'root', - $group = 'root', - $proxy = false, - environment = [] + $ensure = present, + $virtualenv = 'system', + $url = false, + $owner = 'root', + $proxy = false, + $environment = [] ) { # Parameter validation @@ -42,7 +41,7 @@ define python::pip ( fail('python::pip: virtualenv parameter must not be empty') } - if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { + if $virtualenv == 'system' and $owner != 'root' { fail('python::pip: root user must be used when virtualenv is system') } -- cgit v1.2.3 From 01bf2791ecadfbb954b947fefa8b15ca0c0b9947 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Tue, 4 Jun 2013 09:36:33 +1000 Subject: Amended all documentation and updated version to 1.1.0 --- manifests/pip.pp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 3940374..a9805d3 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -13,9 +13,15 @@ # [*url*] # URL to install from. Default: none # +# [*owner*] +# The owner of the virtualenv being manipulated. Default: root +# # [*proxy*] # Proxy server to use for outbound connections. Default: none # +# [*environment*] +# Additional environment variables required to install the packages. Default: none +# # === Examples # # python::pip { 'flask': @@ -26,6 +32,7 @@ # === Authors # # Sergey Stankevich +# Fotis Gimian # define python::pip ( $ensure = present, -- cgit v1.2.3 From 8608958fe1bb7fec4bb75c65bd6b1f1e236e88bd Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Tue, 4 Jun 2013 11:25:48 +1000 Subject: Removed unnecessary which commands for obtaining the pip and python executables --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index a9805d3..ddbcd6f 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -58,7 +58,7 @@ define python::pip ( } $pip_env = $virtualenv ? { - 'system' => '`which pip`', + 'system' => 'pip', default => "${virtualenv}/bin/pip", } -- cgit v1.2.3 From a2e66713c380c81a484583a3a33ff6dead87a496 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Wed, 9 Oct 2013 15:56:13 +0200 Subject: Add options install_args and uninstall_args. Modern pip does not install what it considers 'pre-release' versions unless '--pre' is given as argument. This change adds a mechanism for supplying the '--pre' argument or any other argument deemed necessary. --- manifests/pip.pp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index ddbcd6f..1d576e0 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -35,12 +35,14 @@ # Fotis Gimian # define python::pip ( - $ensure = present, - $virtualenv = 'system', - $url = false, - $owner = 'root', - $proxy = false, - $environment = [] + $ensure = present, + $virtualenv = 'system', + $url = false, + $owner = 'root', + $proxy = false, + $environment = [], + $install_args = '', + $uninstall_args = '', ) { # Parameter validation @@ -80,7 +82,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log-file ${cwd}/pip.log install ${proxy_flag} ${source}", + command => "$pip_env --log-file ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -89,7 +91,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall ${proxy_flag} ${name}", + command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From b84a20709beecc417893fdee4e25060ea63fab21 Mon Sep 17 00:00:00 2001 From: Vik Bhatti Date: Tue, 15 Oct 2013 13:38:38 +0100 Subject: Added support for setting egg name --- manifests/pip.pp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 1d576e0..8bd21d3 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -40,6 +40,7 @@ define python::pip ( $url = false, $owner = 'root', $proxy = false, + $egg = false, $environment = [], $install_args = '', $uninstall_args = '', @@ -74,9 +75,14 @@ define python::pip ( default => "^${name}==", } + $egg_name = $egg ? { + false => $name, + default => $egg + } + $source = $url ? { false => $name, - default => "${url}#egg=${name}", + default => "${url}#egg=${egg_name}", } case $ensure { -- cgit v1.2.3 From 65bf6fe8b6cf23050e755d62291f56f7e8654ede Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 19 Oct 2013 16:10:59 +0300 Subject: pip log option. Fixes #28 --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 8bd21d3..3ca33a8 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -88,7 +88,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log-file ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From be335fa2048a60921b0896c770d87a60b53c4aea Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 16:36:28 -0500 Subject: Add path to pip when executed out of virtualenv --- manifests/pip.pp | 1 + 1 file changed, 1 insertion(+) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index ddbcd6f..a6faea8 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -84,6 +84,7 @@ define python::pip ( unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, + path => [ '/usr/bin', '/usr/local/bin/' ], } } -- cgit v1.2.3 From 52dfd22110ab3fdf83edb11868c53803d9f82b45 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 17:24:53 -0500 Subject: Fix paths --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index a6faea8..6075c3a 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -84,7 +84,7 @@ define python::pip ( unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => [ '/usr/bin', '/usr/local/bin/' ], + path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], } } -- cgit v1.2.3 From a1fc8ab73c6c34413e2957bea1d3a6719e4612c4 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 18:01:16 -0500 Subject: Add path to pip install/uninstall --- manifests/pip.pp | 1 + 1 file changed, 1 insertion(+) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 6075c3a..f64ea97 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -94,6 +94,7 @@ define python::pip ( onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, + path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], } } } -- cgit v1.2.3 From 99a7bbbf8a0d4db3a2abba9f4a47ac65c223bbaa Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 18:05:06 -0500 Subject: Fix paths --- manifests/pip.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index f64ea97..9589b1a 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -84,7 +84,7 @@ define python::pip ( unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], } } @@ -94,7 +94,7 @@ define python::pip ( onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], } } } -- cgit v1.2.3 From 2e3784ba2c93f8240648682ce0b3c14bcb8605a7 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 18:46:52 -0500 Subject: Added latest support to pip, fixed log param --log-file is not supported in older versions, changed to use --log Added ability to do pip --upgrade by using latest --- manifests/pip.pp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 9589b1a..0bed6dc 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -80,7 +80,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log-file ${cwd}/pip.log install ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -88,6 +88,15 @@ define python::pip ( } } + latest: { + exec { "pip_install_${name}": + command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + user => $owner, + environment => $environment, + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + } + } + default: { exec { "pip_uninstall_${name}": command => "echo y | $pip_env uninstall ${proxy_flag} ${name}", -- cgit v1.2.3 From 8bf9aac814812d0235ee5aa08e097d6dd03c188d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Jagodzi=C5=84ski?= Date: Mon, 18 Nov 2013 08:27:57 +0100 Subject: Add to python::pip ensure => latest --- manifests/pip.pp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 3ca33a8..7b51439 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -95,6 +95,14 @@ define python::pip ( } } + latest: { + exec { "pip_install_${name}": + command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${proxy_flag} ${source}", + user => $owner, + environment => $environment, + } + } + default: { exec { "pip_uninstall_${name}": command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", -- cgit v1.2.3 From 535115b9d1426a4d380dc4631fdd2944e0c29e88 Mon Sep 17 00:00:00 2001 From: Neil Saunders Date: Thu, 19 Dec 2013 18:06:25 +0000 Subject: Fixing lint issues as per http://docs.puppetlabs.com/guides/style_guide.html --- manifests/pip.pp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index bcb7911..ebe549b 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -57,7 +57,7 @@ define python::pip ( $cwd = $virtualenv ? { 'system' => '/', - default => "${virtualenv}", + default => $virtualenv, } $pip_env = $virtualenv ? { @@ -88,26 +88,26 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", - unless => "$pip_env freeze | grep -i -e ${grep_regex}", + command => "${pip_env} --log ${cwd}/pip.log install ${install_args} ${proxy_flag} ${source}", + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + command => "${pip_env} --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", user => $owner, environment => $environment, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${proxy_flag} ${source}", + command => "${pip_env} --log ${cwd}/pip.log install -U ${install_args} ${proxy_flag} ${source}", user => $owner, environment => $environment, } @@ -115,11 +115,11 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", - onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}", + onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } } -- cgit v1.2.3 From 5dfe3e57489790823928a90363d7ab81500ce5e8 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 12:45:56 -0500 Subject: Fix wheel flag for pip commands Python 2.6 does not support setuptools < 0.8 which is required for pip wheel support, older versions need to use the --no-use-wheel flag --- manifests/pip.pp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index bcb7911..ba83658 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,6 +70,14 @@ define python::pip ( default => "--proxy=${proxy}", } + # Python 2.6 and older don't support setuptools > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag + if ( versioncmp($::python_version,'2.6') > 0 ) { + $wheel_support_flag = '--no-use-wheel' + } else { + $wheel_support_flag = '' + } + $grep_regex = $name ? { /==/ => "^${name}\$", default => "^${name}==", @@ -88,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install $install_args ${wheel_support_flag} ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -98,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install --upgrade ${wheel_support_flag} ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -107,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${wheel_support_flag} ${proxy_flag} ${source}", user => $owner, environment => $environment, } @@ -115,7 +123,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", + command => "echo y | $pip_env uninstall $uninstall_args ${wheel_support_flag} ${proxy_flag} ${name}", onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 6d88eb88f3ec00655a25f9cb83efd58f293ef4fe Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:25:27 -0500 Subject: Fix wheel support and pip version compatability Fix wheel support and compatability for older pip versions by detecting suppport when running the pip command inside a virtualenv. --- manifests/pip.pp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index ba83658..a818e23 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,13 +70,6 @@ define python::pip ( default => "--proxy=${proxy}", } - # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag - if ( versioncmp($::python_version,'2.6') > 0 ) { - $wheel_support_flag = '--no-use-wheel' - } else { - $wheel_support_flag = '' - } $grep_regex = $name ? { /==/ => "^${name}\$", @@ -93,10 +86,17 @@ define python::pip ( default => "${url}#egg=${egg_name}", } + # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag if the + # pip version is more recent thatn 1.4.1 but using an old python or + # setuputils/distribute version + # To check for this we test for wheel parameter using help and then using + # version, this makes sure we only use wheels if they are supported + case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } -- cgit v1.2.3 From a49582f22a71baf746ff06c10850a207a99a9750 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:32:51 -0500 Subject: Fix quoting of exec commands to use single quotes --- manifests/pip.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index a818e23..6c0425e 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -96,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || 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 && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } -- cgit v1.2.3 From 10633ecbde7bd269e0e02d1ae5ba5313bc00c24b Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:56:38 -0500 Subject: Fix handling of wheel support for initial pip --- manifests/pip.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 6c0425e..5849ca9 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -86,9 +86,9 @@ define python::pip ( default => "${url}#egg=${egg_name}", } - # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag if the - # pip version is more recent thatn 1.4.1 but using an old python or + # Python 2.6 and older does not support setuptools/distribute > 0.8 which + # is required for pip wheel support, pip therefor requires --no-use-wheel flag + # if the # pip version is more recent than 1.4.1 but using an old python or # setuputils/distribute version # To check for this we test for wheel parameter using help and then using # version, this makes sure we only use wheels if they are supported -- cgit v1.2.3 From 44acbef424819e226bec875aabf3db44a06b7015 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 16:01:36 -0500 Subject: Fix simple typo --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 5849ca9..5e287f7 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], -- cgit v1.2.3 From f2266d7070a3c6f1a07b7746448c647e3bc37b88 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 16:14:57 -0500 Subject: Fix bash logic false positives --- manifests/pip.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 5e287f7..5c218c5 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -96,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || 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 && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || 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 && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } -- cgit v1.2.3 From 1087abd3ba21bcb5b33f7c40f07724c1b9a093eb Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 09:34:04 -0500 Subject: Further fixes for pip 1.5 and wheel handling --- manifests/pip.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 5c218c5..e9ab7cd 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -96,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && (pip wheel --version || 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 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}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && (pip wheel --version || 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 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}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help > /dev/null 2>&1&& { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } -- cgit v1.2.3 From 895eebf2a03a29959d0c4dbd613cfa345ac22b55 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 10:53:24 -0500 Subject: Cleanup for merge request --- manifests/pip.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index e9ab7cd..f71cdcd 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,7 +70,6 @@ define python::pip ( default => "--proxy=${proxy}", } - $grep_regex = $name ? { /==/ => "^${name}\$", default => "^${name}==", @@ -123,7 +122,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall $uninstall_args ${wheel_support_flag} ${proxy_flag} ${name}", + command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 05fc36b8d6f0a9eaeedd72a9dbbbe899aeeed8e2 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 14 Jan 2014 17:02:38 -0500 Subject: Update documentation for python pip --- manifests/pip.pp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index fb73ae7..367cdb3 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -85,12 +85,20 @@ define python::pip ( default => "${url}#egg=${egg_name}", } - # Python 2.6 and older does not support setuptools/distribute > 0.8 which - # is required for pip wheel support, pip therefor requires --no-use-wheel flag - # if the # pip version is more recent than 1.4.1 but using an old python or - # setuputils/distribute version + # We need to jump through hoops to make sure we issue the correct pip command + # depending on wheel support and versions. + # + # Pip does not support wheels prior to version 1.4.0 + # Pip wheels require setuptools/distribute > 0.8 + # Python 2.6 and older does not support setuptools/distribute > 0.8 + # Pip >= 1.5 tries to use wheels by default, even if wheel package is not + # installed, in this case the --no-use-wheel flag needs to be passed + # Versions prior to 1.5 don't support the --no-use-wheel flag + # # To check for this we test for wheel parameter using help and then using - # version, this makes sure we only use wheels if they are supported + # version, this makes sure we only use wheels if they are supported and + # installed + case $ensure { present: { -- cgit v1.2.3 From dba29a61bda4ab44ec8c42a43583d0e51f3806d9 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Thu, 16 Jan 2014 01:19:41 +0100 Subject: remove duplicate pip_install exec for latest case --- manifests/pip.pp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index fb73ae7..4aacb31 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -112,14 +112,6 @@ define python::pip ( } } - latest: { - 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 -U ${install_args} \$wheel_support_flag ${proxy_flag} ${source}", - user => $owner, - environment => $environment, - } - } - default: { exec { "pip_uninstall_${name}": command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}", -- cgit v1.2.3 From c298a80bc32e3dda2e6b0d1deb839cc2831f646e Mon Sep 17 00:00:00 2001 From: Marcin Zaremba Date: Thu, 6 Mar 2014 15:33:02 +0100 Subject: adds external pkgname variable --- manifests/pip.pp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 4f91e59..7e332fe 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -4,6 +4,12 @@ # # === Parameters # +# [*name] +# must be unique +# +# [*pkgname] +# name of the package. +# # [*ensure*] # present|absent. Default: present # @@ -35,6 +41,7 @@ # Fotis Gimian # define python::pip ( + $pkgname = undef, $ensure = present, $virtualenv = 'system', $url = false, @@ -70,18 +77,18 @@ define python::pip ( default => "--proxy=${proxy}", } - $grep_regex = $name ? { - /==/ => "^${name}\$", - default => "^${name}==", + $grep_regex = $pkgname ? { + /==/ => "^${pkgname}\$", + default => "^${pkgname}==", } $egg_name = $egg ? { - false => $name, + false => $pkgname, default => $egg } $source = $url ? { - false => $name, + false => $pkgname, default => "${url}#egg=${egg_name}", } @@ -122,7 +129,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${pkgname}", onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 066a10ea68c340773a94d19769ff77c02c39f128 Mon Sep 17 00:00:00 2001 From: Nathan Sullivan Date: Tue, 18 Mar 2014 13:15:32 +1000 Subject: add support for explicit version handling with ensure parameter for pip packages --- manifests/pip.pp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 7e332fe..cbd2ed8 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -77,18 +77,29 @@ define python::pip ( default => "--proxy=${proxy}", } - $grep_regex = $pkgname ? { - /==/ => "^${pkgname}\$", - default => "^${pkgname}==", + # 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}\$" + } else { + $grep_regex = $use_pkgname ? { + /==/ => "^${use_pkgname}\$", + default => "^${use_pkgname}==", + } } $egg_name = $egg ? { - false => $pkgname, + false => $use_pkgname, default => $egg } $source = $url ? { - false => $pkgname, + false => $use_pkgname, default => "${url}#egg=${egg_name}", } @@ -108,7 +119,20 @@ define python::pip ( case $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]+)?)$/: { + # 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}", + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", + user => $owner, + environment => $environment, + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + } + } + 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}", unless => "${pip_env} freeze | grep -i -e ${grep_regex}", @@ -119,6 +143,7 @@ define python::pip ( } 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}", user => $owner, @@ -128,8 +153,9 @@ define python::pip ( } default: { + # Anti-action, uninstall. exec { "pip_uninstall_${name}": - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${pkgname}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${use_pkgname}", onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 0ce45d0b9a82bba68c4fd19c3b95551ede848dfc Mon Sep 17 00:00:00 2001 From: Giacomo Vacca Date: Tue, 18 Mar 2014 11:14:29 +0000 Subject: Don't try to reinstall pip packages on every Puppet run #59; Even if ensure latest, do not install if already latest --- manifests/pip.pp | 1 + 1 file changed, 1 insertion(+) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 7e332fe..47e9732 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -121,6 +121,7 @@ define python::pip ( latest: { 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}", + unless => "${pip_env} search ${source} | grep -i INSTALLED | grep -i latest", user => $owner, environment => $environment, path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], -- cgit v1.2.3 From 7c7afae3abdb0924fdc362a42ad3cd60644b910e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Sun, 6 Apr 2014 12:40:46 +0200 Subject: simplify pkgname default rather than having a rather ugly if and an unhandy case new variable, we can simplify this by making the default $name, in the parameter list. --- manifests/pip.pp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index bf987a4..0c78903 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -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 @@ -41,7 +41,7 @@ # Fotis Gimian # define python::pip ( - $pkgname = undef, + $pkgname = $name, $ensure = present, $virtualenv = 'system', $url = false, @@ -77,29 +77,23 @@ define python::pip ( 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}", } -- cgit v1.2.3 From d0d3e37f2bc4c0c4473e2cb586c61e3d3359637c Mon Sep 17 00:00:00 2001 From: Ali Asad Lotia Date: Thu, 24 Apr 2014 13:21:52 +0100 Subject: Add editable flag. Check passed arguments. --- manifests/pip.pp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 0c78903..637960b 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -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': @@ -48,6 +59,7 @@ define python::pip ( $owner = 'root', $proxy = false, $egg = false, + $editable = false, $environment = [], $install_args = '', $uninstall_args = '', @@ -77,6 +89,22 @@ define python::pip ( 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}\$" @@ -117,7 +145,7 @@ define python::pip ( # 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, @@ -128,7 +156,7 @@ define python::pip ( 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, @@ -139,7 +167,7 @@ define python::pip ( 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, -- cgit v1.2.3 From 8268d348d7c4653a3120345e8796e9a888f5d613 Mon Sep 17 00:00:00 2001 From: Luca Invernizzi Date: Thu, 24 Apr 2014 13:15:47 -0700 Subject: Fixed $(ensure typo in pip.pp --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 637960b..a0c0eb4 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -101,7 +101,7 @@ define python::pip ( fail('python::pip cannot provide install_args with ensure => absent') } - if $(ensure == present) and ($uninstall_args != '') { + if ($ensure == present) and ($uninstall_args != '') { fail('python::pip cannot provide uninstall_args with ensure => present') } -- cgit v1.2.3 From 95747cdbb5e5e7378fd2a8f74a01f0d44bf90e74 Mon Sep 17 00:00:00 2001 From: Steven Pecht Date: Wed, 7 May 2014 14:18:26 -0400 Subject: Added timeout option to python::pip The default timeout is set to 1800. The same default as virtual environement installations. A timeout parameter is needed for long running installs such as SciPy. --- manifests/pip.pp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index a0c0eb4..2cb5bd5 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -31,6 +31,9 @@ # [*environment*] # Additional environment variables required to install the packages. Default: none # +# [*timeout*] +# The maximum time in seconds the "pip install" command should take. Default: 1800 +# # [*install_args*] # String. Any additional installation arguments that will be supplied # when running pip install. @@ -63,6 +66,7 @@ define python::pip ( $environment = [], $install_args = '', $uninstall_args = '', + $timeout = 1800, ) { # Parameter validation @@ -150,6 +154,7 @@ define python::pip ( user => $owner, environment => $environment, path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + timeout => $timeout, } } @@ -161,6 +166,7 @@ define python::pip ( user => $owner, environment => $environment, path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + timeout => $timeout, } } @@ -172,6 +178,7 @@ define python::pip ( user => $owner, environment => $environment, path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + timeout => $timeout, } } @@ -183,6 +190,7 @@ define python::pip ( user => $owner, environment => $environment, path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + timeout => $timeout, } } } -- cgit v1.2.3 From 71a649190bafe3ff114e6eee3655bfbcb24bb22e Mon Sep 17 00:00:00 2001 From: Simon Tremblay Date: Thu, 17 Jul 2014 09:59:10 -0400 Subject: Fixed pip wheel as it was done for virtualenv pip --- manifests/pip.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 2cb5bd5..247295c 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -149,7 +149,7 @@ define python::pip ( # 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} ${install_args} ${install_editable} ${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} || ${pip_env} --log ${cwd}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source}==${ensure} ;}", unless => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -161,7 +161,7 @@ define python::pip ( 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 \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${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} || ${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${install_args} ${install_editable} ${source} ;}", unless => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -173,7 +173,7 @@ define python::pip ( 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} ${uninstall_args} ${install_editable} ${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} || ${pip_env} --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${uninstall_args} ${install_editable} ${source} ;}", unless => "${pip_env} search ${source} | grep -i INSTALLED | grep -i latest", user => $owner, environment => $environment, -- cgit v1.2.3 From 676be6403c428fa9e7c0bb7195484669b08333e9 Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Sun, 27 Jul 2014 17:59:03 +1000 Subject: puppet-lint: removed unused var 'use_pkgname' --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/pip.pp') diff --git a/manifests/pip.pp b/manifests/pip.pp index 247295c..dd2be0d 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -185,7 +185,7 @@ define python::pip ( default: { # Anti-action, uninstall. exec { "pip_uninstall_${name}": - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${use_pkgname}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag}", onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3