Skip to content

Commit

Permalink
Merge pull request #49 from jalli/master
Browse files Browse the repository at this point in the history
Add compatability/support for pip 1.5 and fix erroneous rebuilds
  • Loading branch information
stankevich committed Jan 4, 2014
2 parents 2bab9c9 + b5f48bc commit 45c01b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/facter/pip_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Facter.add("pip_version") do
has_weight 100
setcode do
Facter::Util::Resolution.exec('pip --version')
/^pip (\d+\.\d+\.?\d*).*$/.match(Facter::Util::Resolution.exec('pip --version'))[1]
end
end

Expand Down
13 changes: 10 additions & 3 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,17 @@
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
# 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} ${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 ${install_args} \$wheel_support_flag ${proxy_flag} ${source}",
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
environment => $environment,
Expand All @@ -98,7 +105,7 @@

latest: {
exec { "pip_install_${name}":
command => "${pip_env} --log ${cwd}/pip.log install --upgrade ${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} ${source}",
user => $owner,
environment => $environment,
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
Expand All @@ -107,7 +114,7 @@

latest: {
exec { "pip_install_${name}":
command => "${pip_env} --log ${cwd}/pip.log install -U ${install_args} ${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 -U ${install_args} \$wheel_support_flag ${proxy_flag} ${source}",
user => $owner,
environment => $environment,
}
Expand Down
15 changes: 11 additions & 4 deletions manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,25 @@
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} --upgrade pip ${distribute_pkg}",
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=[\'\"]*/tmp[\"\']*[ \t]*$' /tmp/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} -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,
Expand Down

0 comments on commit 45c01b6

Please sign in to comment.