From 450b39e7bb3b2233f8255c609ff3d8875fcb951a Mon Sep 17 00:00:00 2001 From: Matthias Baur Date: Mon, 25 Nov 2019 17:06:14 +0100 Subject: [PATCH] Upgrade pip and setuptools on venv creation --- manifests/pyvenv.pp | 4 +++- spec/defines/pyvenv_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 5ae6eef3..dfdd5965 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -81,8 +81,10 @@ mode => $mode, } + $pip_cmd = "${python::exec_prefix}${venv_dir}/bin/pip" + exec { "python_virtualenv_${venv_dir}": - command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${venv_dir}", + command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${venv_dir} && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade pip && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade setuptools", user => $owner, creates => "${venv_dir}/bin/activate", path => $_path, diff --git a/spec/defines/pyvenv_spec.rb b/spec/defines/pyvenv_spec.rb index 81ec3fd1..73df2f1c 100644 --- a/spec/defines/pyvenv_spec.rb +++ b/spec/defines/pyvenv_spec.rb @@ -15,7 +15,7 @@ context 'with default parameters' do it { is_expected.to contain_file('/opt/env') } - it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env') } + it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') } if %w[xenial bionic cosmic disco jessie stretch buster].include?(facts[:lsbdistcodename]) it { is_expected.to contain_package('python3.5-venv').that_comes_before('File[/opt/env]') }