Skip to content

Commit 5c5ac01

Browse files
committed
allow all python versions
Fixes issue voxpupuli#448, "Impossible to use version number in Ubuntu 16.04" 1) It does not make sense to restrict the allowed python versions per distribution. Newer distribution releases add new python versions and you can add repositories containing backports. 2) The List was outdated. Note: python version is needed for spec test
1 parent 796680d commit 5c5ac01

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

manifests/init.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
default => '',
6262
}
6363

64-
$allowed_versions = concat(['system', 'pypy'], $valid_versions)
65-
unless $version =~ Enum[$allowed_versions] {
66-
fail("version needs to be within${allowed_versions}")
64+
unless $version =~ Pattern[/\A(python)?[0-9](\.[0-9])+/,
65+
/\Apypy\Z/, /\Asystem\Z/] {
66+
fail("version needs to be pypy, system or a version string like '3.5' or 'python3.5)")
6767
}
6868

6969
# Module compatibility check

manifests/install.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
$python = $::python::version ? {
1010
'system' => 'python',
1111
'pypy' => 'pypy',
12-
default => "${python::version}", # lint:ignore:only_variable_string
12+
/\A(python)?([0-9](\.[0-9])+)/ => "python${1}",
13+
default => "python${python::version}",
1314
}
1415

1516
$pythondev = $::osfamily ? {

manifests/params.pp

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
$gunicorn = 'absent'
1111
$manage_gunicorn = true
1212
$provider = undef
13-
$valid_versions = $::osfamily ? {
14-
'RedHat' => ['3','27','33'],
15-
'Debian' => ['3', '3.3', '2.7'],
16-
'Suse' => [],
17-
'Gentoo' => ['2.7', '3.3', '3.4', '3.5']
18-
}
13+
$valid_versions = undef
1914

2015
if $::osfamily == 'RedHat' {
2116
if $::operatingsystem != 'Fedora' {

manifests/pyvenv.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737

3838
if $ensure == 'present' {
3939
$python_version = $version ? {
40-
'system' => "$::python3_version",
41-
default => "${version}",
40+
'system' => $facts['python3_version'],
41+
default => $version,
4242
}
4343

4444
# Debian splits the venv module into a seperate package
4545
if ( $facts['os']['family'] == 'Debian'){
4646
$python3_venv_package="python${python_version}-venv"
47-
case $facts['os']['distro']['codename'] {
48-
'xenial','bionic','cosmic','disco',
47+
case $facts['lsbdistcodename'] {
48+
'xenial','bionic','cosmic','disco',
4949
'jessie','stretch','buster': {
5050
package {$python3_venv_package:
5151
before => File[$venv_dir],
@@ -56,7 +56,7 @@
5656
}
5757

5858
# pyvenv is deprecated since 3.6 and will be removed in 3.8
59-
if (versioncmp($::python3_version, '3.6') >=0) {
59+
if (versioncmp($facts['python3_version'], '3.6') >=0) {
6060
$virtualenv_cmd = "${python::exec_prefix}python${python_version} -m venv"
6161
} else {
6262
$virtualenv_cmd = "${python::exec_prefix}pyvenv-${python_version}"

spec/default_module_facts.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
python_version: "2.7"
3+
python3_version: ~

spec/defines/pyvenv_spec.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
on_supported_os.each do |os, facts|
55
context("on #{os} ") do
66
let :facts do
7-
facts
7+
# python3 is required to use pyvenv
8+
facts.merge(
9+
python3_version: '3.4'
10+
)
811
end
912
let :title do
1013
'/opt/env'
1114
end
1215

1316
it {
1417
is_expected.to contain_file('/opt/env')
15-
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv --clear /opt/env')
18+
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.4 --clear /opt/env')
1619
}
1720

1821
describe 'when ensure' do
@@ -28,6 +31,6 @@
2831
}
2932
end
3033
end
31-
end
34+
end # context
3235
end
3336
end

0 commit comments

Comments
 (0)