From bdd11b065f665175ecc51ca4ead307e0be6cdd22 Mon Sep 17 00:00:00 2001 From: John Bond Date: Thu, 5 Dec 2019 16:02:19 +0100 Subject: [PATCH] Allow minor version in python::version e.g. python3.7 --- manifests/install.pp | 11 ++++++----- spec/classes/python_spec.rb | 9 +++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 8b409794..4bb3640e 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -7,11 +7,12 @@ class python::install { $python = $python::version ? { - 'system' => 'python', - 'pypy' => 'pypy', - /\A(python)?([0-9]+)/ => "python${2}", - /\Arh-python[0-9]{2}/ => $python::version, - default => "python${python::version}", + 'system' => 'python', + 'pypy' => 'pypy', + /\A(python)?(\d)\.(\d)/ => "python${2}.${3}", + /\A(python)?(\d+)/ => "python${2}", + /\Arh-python\d{2}/ => $python::version, + default => "python${python::version}", } $pythondev = $facts['os']['family'] ? { diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index d5d3fbeb..f0fb5293 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -21,6 +21,15 @@ # Basic python packages (from pip) it { is_expected.to contain_package('virtualenv') } + describe 'with python::version' do + context 'python3.7' do + let(:params) { { version: 'python3.7' } } + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_package('python').with_name('python3.7') } + end + end + describe 'with python::dev' do context 'true' do let(:params) { { dev: 'present' } }