Skip to content

Commit

Permalink
OPS-69105 proper command for python > 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Krzyżaniak (eloy) committed Jan 27, 2022
1 parent bb1bf92 commit c269d32
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? {
Expand Down

0 comments on commit c269d32

Please sign in to comment.