From 4f2c04b70452249e6917859fdbf02bd90ec3af79 Mon Sep 17 00:00:00 2001 From: Antonis Christofides Date: Tue, 8 Oct 2013 17:59:17 +0300 Subject: Added src parameter for pip in python::requirements A requirements file can have --editable resources; in such a case the pip default is to install them in ~/src/, which can be unsuitable; for example, if run by root, /root/src/ is usually unreadable by other users. pip provides an --src parameter to specify an alternative directory. This is useful for installing requirements systemwide, outside a virtualenv. --- manifests/requirements.pp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 67906fc..60c5b6c 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -19,6 +19,11 @@ # [*proxy*] # Proxy server to use for outbound connections. Default: none # +# [*src*] +# Pip --src parameter; if the requirements file contains --editable resources, +# this parameter specifies where they will be installed. See the pip +# documentation for more. Default: none (i.e. use the pip default). +# # [*environment*] # Additional environment variables required to install the packages. Default: none # @@ -41,6 +46,7 @@ define python::requirements ( $owner = 'root', $group = 'root', $proxy = false, + $src = false, $environment = [] ) { @@ -63,6 +69,11 @@ define python::requirements ( default => "--proxy=${proxy}", } + $src_flag = $src ? { + false => '', + default => "--src=${src}", + } + # This will ensure multiple python::virtualenv definitions can share the # the same requirements file. if !defined(File[$requirements]) { @@ -79,7 +90,7 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} -r ${requirements}", + command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", refreshonly => true, timeout => 1800, user => $owner, -- 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') 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') 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') 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 8a68085f7450f95ca736c690e14b58a0998a13f1 Mon Sep 17 00:00:00 2001 From: Justin Quick Date: Thu, 7 Nov 2013 15:57:10 -0500 Subject: added cwd parameter, made timeout configurable --- manifests/virtualenv.pp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'manifests') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index bdcfc6f..8fc17a9 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -66,7 +66,9 @@ define python::virtualenv ( $group = 'root', $proxy = false, $environment = [], - $path = [ '/bin', '/usr/bin', '/usr/sbin' ] + $path = [ '/bin', '/usr/bin', '/usr/sbin' ], + $cwd = undef, + $timeout = 1800 ) { $venv_dir = $name @@ -115,10 +117,11 @@ define python::virtualenv ( exec { "python_requirements_initial_install_${requirements}_${venv_dir}": command => "${venv_dir}/bin/pip --log-file ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} -r ${requirements}", refreshonly => true, - timeout => 1800, + timeout => $timeout, user => $owner, subscribe => Exec["python_virtualenv_${venv_dir}"], environment => $environment, + cwd => $cwd } python::requirements { "${requirements}_${venv_dir}": -- cgit v1.2.3 From c45a37b5819d3c0dab423b93cefb31e65bddad9d Mon Sep 17 00:00:00 2001 From: Justin Quick Date: Thu, 7 Nov 2013 16:03:28 -0500 Subject: docs --- manifests/virtualenv.pp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'manifests') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 8fc17a9..8486183 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -37,6 +37,12 @@ # [*path*] # Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] # +# [*cwd*] +# The directory from which to run the "pip install" command. Default: undef +# +# [*timeout*] +# The maximum time in seconds the "pip install" command should take. Default: 1800 +# # === Examples # # python::virtualenv { '/var/www/project1': -- 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') 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 0d5e10790f83b6f2662bb89d34c510bb29f403bc Mon Sep 17 00:00:00 2001 From: John Jacobsen Date: Mon, 18 Nov 2013 17:11:24 -0600 Subject: Add support for Scientific Linux Fixes #39. Tested manually in a few cases on a Vagrant Scientific Linux 6 VM and seems to work OK so far. --- manifests/init.pp | 2 +- manifests/install.pp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index 2a9a44c..c4e469d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,7 +42,7 @@ class python ( ) { # Module compatibility check - $compatible = [ 'Debian', 'Ubuntu', 'CentOS', 'RedHat' ] + $compatible = [ 'Debian', 'Ubuntu', 'CentOS', 'RedHat', 'Scientific' ] if ! ($::operatingsystem in $compatible) { fail("Module is not compatible with ${::operatingsystem}") } diff --git a/manifests/install.pp b/manifests/install.pp index 9306e3a..415092e 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -6,8 +6,8 @@ class python::install { } $pythondev = $::operatingsystem ? { - /(?i:RedHat|CentOS|Fedora)/ => "${python}-devel", - /(?i:Debian|Ubuntu)/ => "${python}-dev" + /(?i:RedHat|CentOS|Fedora|Scientific)/ => "${python}-devel", + /(?i:Debian|Ubuntu)/ => "${python}-dev" } package { $python: ensure => present } -- cgit v1.2.3