From c269d32e89909a4639b5172a4c1b2c7005a5aead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Krzy=C5=BCaniak=20=28eloy=29?= Date: Thu, 27 Jan 2022 11:33:51 +0100 Subject: [PATCH] OPS-69105 proper command for python > 3.6 --- manifests/pyvenv.pp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 66957731..4c3bcd12 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -36,10 +36,31 @@ include ::python if $ensure == 'present' { + $python_version = $version ? { + 'system' => $facts['python3_version'], + default => $version, + } + + $python_version_parts = split($python_version, '[.]') + $normalized_python_version = sprintf('%s.%s', $python_version_parts[0], $python_version_parts[1]) - $virtualenv_cmd = $version ? { - 'system' => "${python::exec_prefix}pyvenv", - default => "${python::exec_prefix}pyvenv-${version}", + # Debian splits the venv module into a seperate package + if ( $facts['os']['family'] == 'Debian') { + $python3_venv_package="python${normalized_python_version}-venv" + case $facts['os']['distro']['codename'] { + 'xenial','bionic','cosmic','disco','stretch','buster': { + ensure_packages ($python3_venv_package) + Package[$python3_venv_package] -> File[$venv_dir] + } + default: {} + } + } + + # pyvenv is deprecated since 3.6 and will be removed in 3.8 + if (versioncmp($normalized_python_version, '3.6') >=0) { + $virtualenv_cmd = "${python::exec_prefix}python${normalized_python_version} -m venv" + } else { + $virtualenv_cmd = "${python::exec_prefix}pyvenv-${normalized_python_version}" } $_path = $::python::provider ? {