From 02404243bea7b3b73a144ab6ddb06c3c17181181 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Wed, 23 Dec 2020 10:41:51 -0500 Subject: [PATCH 1/2] Fix pyvenv on some operating systems --- manifests/pyvenv.pp | 7 +++++++ spec/defines/pyvenv_spec.rb | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 269cf69c..7abc33d3 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -49,6 +49,13 @@ ensure_packages($python3_venv_package) Package[$python3_venv_package] -> File[$venv_dir] + + if $facts['os']['distro']['codename'] in ['buster','bionic'] { + $python3_distutils_package = "python${normalized_python_version}-distutils" + ensure_packages($python3_distutils_package) + + Package[$python3_distutils_package] -> File[$venv_dir] + } } # pyvenv is deprecated since 3.6 and will be removed in 3.8 diff --git a/spec/defines/pyvenv_spec.rb b/spec/defines/pyvenv_spec.rb index 36452839..9492a6f7 100644 --- a/spec/defines/pyvenv_spec.rb +++ b/spec/defines/pyvenv_spec.rb @@ -21,6 +21,10 @@ if %w[xenial bionic cosmic disco stretch buster].include?(facts[:lsbdistcodename]) it { is_expected.to contain_package('python3.5-venv').that_comes_before('File[/opt/env]') } end + + if %w[bionic buster].include?(facts[:lsbdistcodename]) + it { is_expected.to contain_package('python3.5-distutils').that_comes_before('File[/opt/env]') } + end end describe 'when ensure' do From f5ed0898e4d39d8ff7b6f1b2a42769f6d93b6b17 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Wed, 23 Dec 2020 11:01:44 -0500 Subject: [PATCH 2/2] Install python3-venv instead of python3.x-venv for Debian 10 and Ubuntu 18.04 --- manifests/pyvenv.pp | 16 ++++++++-------- spec/defines/pyvenv_spec.rb | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 7abc33d3..17838633 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -45,16 +45,16 @@ # Debian splits the venv module into a seperate package if ( $facts['os']['family'] == 'Debian') { - $python3_venv_package = "python${normalized_python_version}-venv" - ensure_packages($python3_venv_package) - - Package[$python3_venv_package] -> File[$venv_dir] - if $facts['os']['distro']['codename'] in ['buster','bionic'] { - $python3_distutils_package = "python${normalized_python_version}-distutils" - ensure_packages($python3_distutils_package) + $python3_venv_package = "python${$python_version_parts[0]}-venv" + ensure_packages($python3_venv_package) + + Package[$python3_venv_package] -> File[$venv_dir] + } else { + $python3_venv_package = "python${normalized_python_version}-venv" + ensure_packages($python3_venv_package) - Package[$python3_distutils_package] -> File[$venv_dir] + Package[$python3_venv_package] -> File[$venv_dir] } } diff --git a/spec/defines/pyvenv_spec.rb b/spec/defines/pyvenv_spec.rb index 9492a6f7..9e074a56 100644 --- a/spec/defines/pyvenv_spec.rb +++ b/spec/defines/pyvenv_spec.rb @@ -18,12 +18,12 @@ 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 && /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 stretch buster].include?(facts[:lsbdistcodename]) + if %w[xenial cosmic disco stretch].include?(facts[:lsbdistcodename]) it { is_expected.to contain_package('python3.5-venv').that_comes_before('File[/opt/env]') } end if %w[bionic buster].include?(facts[:lsbdistcodename]) - it { is_expected.to contain_package('python3.5-distutils').that_comes_before('File[/opt/env]') } + it { is_expected.to contain_package('python3-venv').that_comes_before('File[/opt/env]') } end end