Skip to content

Commit

Permalink
WIP not committed
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Oct 9, 2024
1 parent 673e4e1 commit 8491f8e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
2 changes: 2 additions & 0 deletions data/os/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
python::version: '39'
9 changes: 9 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
Boolean $manage_dev_package = true,
Boolean $manage_venv_package = $python::params::manage_venv_package,
Boolean $manage_pip_package = $python::params::manage_pip_package,
Optional[String[1]] $pip_package_name = undef,
String[1] $gunicorn_package_name = $python::params::gunicorn_package_name,
Optional[Python::Provider] $provider = undef,
Hash $python_pips = {},
Expand All @@ -68,6 +69,14 @@
default => '',
}

$pip_package_real_name = $pip_package_name.lest || {
fact('os.family') ? {
'FreeBSD' => "py${version}-pip",
default => 'python-pip',
}
}


contain python::install
contain python::config

Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# Respect the $python::pip setting
unless $python::pip == 'absent' {
# Install pip without pip, see https://pip.pypa.io/en/stable/installing/.
include python::pip::bootstrap
contain python::pip::bootstrap

Exec['bootstrap pip'] -> File['pip-python'] -> Package <| provider == pip |>

Expand Down
2 changes: 1 addition & 1 deletion manifests/install/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
'anaconda': {
}
default: {
pip, default: {
case $facts['os']['family'] {
'AIX': {
unless String($python::version) =~ /^python3/ {
Expand Down
29 changes: 29 additions & 0 deletions spec/classes/install_pip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'python::install::pip' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end

context 'with default settings' do
it { is_expected.to contain_package('pip').with(ensure: 'present') }
end

context 'when ensuring pip is absent' do
let(:pre_condition) do
<<~PP
class { 'python':
pip => absent,
}
PP
end

it { is_expected.to contain_package('pip').with(ensure: 'absent') }
end
end
end
end
20 changes: 4 additions & 16 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
it { is_expected.to contain_package('python') }

if facts[:os]['family'] == 'Archlinux'
it { is_expected.not_to contain_package('pip') }
it { is_expected.not_to contain_class('python::install::pip') }
else
it { is_expected.to contain_package('pip') }
it { is_expected.to contain_class('python::install::pip') }
end

if %w[Archlinux].include?(facts[:os]['family'])
Expand All @@ -43,22 +43,10 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_package('python') }
it { is_expected.not_to contain_package('python-dev') }
it { is_expected.not_to contain_package('pip') }
it { is_expected.not_to contain_class('python::install::pip') }
it { is_expected.not_to contain_class('python::install::venv') }
end

context 'with packages present' do
let :params do
{
manage_pip_package: true,
pip: 'present',
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('pip').with(ensure: 'present') }
end

case facts[:os]['family']
when 'Debian'

Expand All @@ -68,7 +56,7 @@
# Base debian packages.
it { is_expected.to contain_package('python') }
it { is_expected.to contain_package('python-dev') }
it { is_expected.to contain_package('pip') }
it { is_expected.to contain_class('python::install::pip') }

describe 'with python::version' do
context 'python3.7' do
Expand Down

0 comments on commit 8491f8e

Please sign in to comment.