Skip to content

Commit

Permalink
Install dev packages in python::install::dev
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Dec 14, 2023
1 parent d6829cc commit b08bf1a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 15 deletions.
5 changes: 5 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#### Public Classes

* [`python`](#python): Installs and manages python, python-dev and gunicorn.
* [`python::install::dev`](#python--install--dev): Installs python development packages
* [`python::pip::bootstrap`](#python--pip--bootstrap): allow to bootstrap pip when python is managed from other module

#### Private Classes
Expand Down Expand Up @@ -289,6 +290,10 @@ Data type: `Stdlib::Absolutepath`

Default value: `'/opt/python'`

### <a name="python--install--dev"></a>`python::install::dev`

Installs python development packages

### <a name="python--pip--bootstrap"></a>`python::pip::bootstrap`

allow to bootstrap pip when python is managed from other module
Expand Down
18 changes: 3 additions & 15 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@
}

if $python::manage_dev_package and $pythondev {
package { 'python-dev':
ensure => $python::dev,
name => $pythondev,
}
contain python::install::dev
}

# Respect the $python::pip setting
Expand Down Expand Up @@ -180,12 +177,7 @@
}

if $python::manage_dev_package and $pythondev {
package { 'python-dev':
ensure => $python::dev,
name => $pythondev,
alias => $pythondev,
provider => 'yum',
}
contain python::install::dev
}
}
default: {
Expand All @@ -197,11 +189,7 @@
}

if $python::manage_dev_package and $pythondev {
package { 'python-dev':
ensure => $python::dev,
name => $pythondev,
alias => $pythondev,
}
contain python::install::dev
}
}
}
Expand Down
38 changes: 38 additions & 0 deletions manifests/install/dev.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# @summary Installs python development packages
class python::install::dev {
include python

case $python::provider {
'pip': {
package { 'python-dev':
ensure => $python::dev,
name => $python::install::pythondev,
}
}
'scl': {
}
'rhscl': {
}
'anaconda': {
}
default: {
case $facts['os']['family'] {
'AIX': {
package { 'python-dev':
ensure => $python::dev,
name => $python::install::pythondev,
alias => $python::install::pythondev,
provider => 'yum',
}
}
default: {
package { 'python-dev':
ensure => $python::dev,
name => $python::install::pythondev,
alias => $python::install::pythondev,
}
}
}
}
}
}
29 changes: 29 additions & 0 deletions spec/classes/install/dev_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::dev' 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('python-dev').with(ensure: 'absent') }
end

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

it { is_expected.to contain_package('python-dev').with(ensure: 'present') }
end
end
end
end

0 comments on commit b08bf1a

Please sign in to comment.