From 0b4438b64eb2f24f9aff75116cbefb3fc85b5241 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Wed, 1 Jan 2014 12:44:24 -0500 Subject: Fix path for unless statement. https://github.com/stankevich/puppet-python/issues/46 --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index bc7141c..f74cc4f 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -125,7 +125,7 @@ define python::virtualenv ( path => $path, cwd => "/tmp", environment => $environment, - unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' /tmp/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { -- cgit v1.2.3 From ae04aad7b8fd5f88f6bc379dbabd21000dcb9a85 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 11:36:39 -0500 Subject: Add flag to disable wheels for python 2.6 Setuptools 0.8 is required for pip wheel support, Python 2.6 and older only support setuptools 0.7, we therefor need to disable wheels. --- manifests/virtualenv.pp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index f74cc4f..3a7997e 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -98,7 +98,7 @@ define python::virtualenv ( default => "&& export http_proxy=${proxy}", } - # Virtualenv versions prior to 1.7 do not support the + # Virtualenv versions prior to 1.7 do not support the # --system-site-packages flag, default off for prior versions # Prior to version 1.7 the default was equal to --system-site-packages # and the flag --no-site-packages had to be passed to do the opposite @@ -110,6 +110,14 @@ define python::virtualenv ( $system_pkgs_flag = '' } + # Python 2.6 and older don't support setuptools > 0.8 which is required + # for pip wheel support, it therefor requires --no-use-wheel flag + if ( versioncmp($::python_version,'2.6') > 0 ) { + $wheel_support_flag = '--no-use-wheel' + } else { + $wheel_support_flag = '' + } + $distribute_pkg = $distribute ? { true => 'distribute', default => '', @@ -120,7 +128,7 @@ define python::virtualenv ( } exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} --upgrade pip ${distribute_pkg}", user => $owner, path => $path, cwd => "/tmp", @@ -130,7 +138,7 @@ define python::virtualenv ( if $requirements { exec { "python_requirements_initial_install_${requirements}_${venv_dir}": - command => "${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} -r ${requirements}", + command => "${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} -r ${requirements}", refreshonly => true, timeout => $timeout, user => $owner, -- 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/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 3a7997e..7b4b53c 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -111,7 +111,7 @@ define python::virtualenv ( } # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, it therefor requires --no-use-wheel flag + # 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 { -- 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/virtualenv.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7b4b53c..7b39212 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -110,9 +110,10 @@ define python::virtualenv ( $system_pkgs_flag = '' } - # 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 ) { + # 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 + # version is newer than 1.4.1 when they added wheels + if (( versioncmp($::python_version,'2.6') > 0 and ( versioncmp($::pip_version,'1.4.1') > 0)) { $wheel_support_flag = '--no-use-wheel' } else { $wheel_support_flag = '' -- cgit v1.2.3 From 784a8bca85023490169bf9663740419caea776a0 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:44:44 -0500 Subject: Fix syntax error in conditional statement --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7b39212..3e61e1f 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -113,7 +113,7 @@ define python::virtualenv ( # 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 # version is newer than 1.4.1 when they added wheels - if (( versioncmp($::python_version,'2.6') > 0 and ( versioncmp($::pip_version,'1.4.1') > 0)) { + if (( versioncmp($::python_version,'2.6') > 0 ) and ( versioncmp($::pip_version,'1.4.1') > 0)) { $wheel_support_flag = '--no-use-wheel' } else { $wheel_support_flag = '' -- 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/virtualenv.pp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 3e61e1f..94bbd15 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -110,15 +110,6 @@ define python::virtualenv ( $system_pkgs_flag = '' } - # 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 - # version is newer than 1.4.1 when they added wheels - if (( versioncmp($::python_version,'2.6') > 0 ) and ( versioncmp($::pip_version,'1.4.1') > 0)) { - $wheel_support_flag = '--no-use-wheel' - } else { - $wheel_support_flag = '' - } - $distribute_pkg = $distribute ? { true => 'distribute', default => '', @@ -128,8 +119,15 @@ define python::virtualenv ( default => "-i ${index}", } + # 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 + exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && ${venv_dir}/bin/pip wheel --version || 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}", user => $owner, path => $path, cwd => "/tmp", -- 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/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 94bbd15..9c9502d 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,7 +127,7 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && ${venv_dir}/bin/pip wheel --version || 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}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && (${venv_dir}/bin/pip wheel --version || 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}", user => $owner, path => $path, cwd => "/tmp", -- 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/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 9c9502d..7a548a6 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,7 +127,7 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && (${venv_dir}/bin/pip wheel --version || 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}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env 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}", user => $owner, path => $path, cwd => "/tmp", -- cgit v1.2.3 From d8a72b218455de66b59af0229ebae2e708538e77 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 10:09:56 -0500 Subject: Fix testing for existing virtual environment --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7a548a6..f3ca1ce 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -132,7 +132,7 @@ define python::virtualenv ( path => $path, cwd => "/tmp", environment => $environment, - unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + 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 } if $requirements { -- cgit v1.2.3 From 7ae9495652889b69543c57869d181e4b479070b4 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 10:49:25 -0500 Subject: Fix grep for detecting if virtenv needs rebuild --- manifests/virtualenv.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index f3ca1ce..cee35fc 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -119,7 +119,7 @@ define python::virtualenv ( default => "-i ${index}", } - # Python 2.6 and older does not support setuptools/distribute > 0.8 which + # 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 @@ -132,7 +132,7 @@ define python::virtualenv ( path => $path, 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 + 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 } if $requirements { -- cgit v1.2.3 From 223da1caddb69418fc1a6383dbb5ea65c9fcdf90 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 11:45:39 -0500 Subject: Fix wheel/pip1.5 handing with requirements --- manifests/virtualenv.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index a779141..fc540a8 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,17 +127,17 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported 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}", - user => $owner, - path => $path, - cwd => "/tmp", + 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}", + user => $owner, + path => $path, + 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 + 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 } if $requirements { exec { "python_requirements_initial_install_${requirements}_${venv_dir}": - command => "${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}", refreshonly => true, timeout => $timeout, user => $owner, -- cgit v1.2.3 From b5f48bc7cc5861dee404d43eed5a6d327d22c54e Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 13:01:45 -0500 Subject: Fix working dir for virtualenv creation --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/virtualenv.pp') diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index fc540a8..7f7fbb4 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -130,7 +130,7 @@ define python::virtualenv ( 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}", user => $owner, path => $path, - cwd => "/tmp", + cwd => $venv_dir, 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 } -- cgit v1.2.3