Skip to content

Commit

Permalink
Add option to install python-setuptools
Browse files Browse the repository at this point in the history
This is required at least on Arch Linux because distutils is provided by
python-setuptools, not python:

https://gitlab.archlinux.org/archlinux/packaging/packages/thefuck/-/issues/1
  • Loading branch information
bastelfreak committed Aug 21, 2024
1 parent 04e4d4c commit 387fa0d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following parameters are available in the `python` class:
* [`manage_dev_package`](#-python--manage_dev_package)
* [`manage_venv_package`](#-python--manage_venv_package)
* [`manage_pip_package`](#-python--manage_pip_package)
* [`manage_setuptools`](#-python--manage_setuptools)
* [`venv`](#-python--venv)
* [`gunicorn_package_name`](#-python--gunicorn_package_name)
* [`python_pips`](#-python--python_pips)
Expand Down Expand Up @@ -217,6 +218,14 @@ manage the state for package pip

Default value: `$python::params::manage_pip_package`

##### <a name="-python--manage_setuptools"></a>`manage_setuptools`

Data type: `Boolean`

if true, install python-setuptools

Default value: `$facts['os']['family'] ? { 'Archlinux' => true, default => false`

##### <a name="-python--venv"></a>`venv`

Data type: `Python::Package::Ensure`
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# @param manage_dev_package manage the state of the python development package
# @param manage_venv_package manage the state for package venv
# @param manage_pip_package manage the state for package pip
# @param manage_setuptools if true, install python-setuptools
#
# @example install python from system python
# class { 'python':
Expand Down Expand Up @@ -61,6 +62,7 @@
Stdlib::Absolutepath $anaconda_install_path = '/opt/python',
Boolean $manage_scl = true,
Optional[Python::Umask] $umask = undef,
Boolean $manage_setuptools = $facts['os']['family'] ? { 'Archlinux' => true, default => false, },
) inherits python::params {
$exec_prefix = $provider ? {
'scl' => "/usr/bin/scl enable ${version} -- ",
Expand Down
6 changes: 6 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
'Suse' => "${python}-devel",
}

if $python::manage_setuptools {
package { 'python-distutils-extra':
ensure => 'installed',
}
}

if $python::manage_python_package {
package { 'python':
ensure => $python::ensure,
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

if facts[:os]['family'] == 'Archlinux'
it { is_expected.not_to contain_package('pip') }
it { is_expected.to contain_package('python-setuptools') }

Check failure on line 22 in spec/classes/python_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

python on archlinux-6-x86_64 with defaults is expected to contain Package[python-setuptools] Failure/Error: it { is_expected.to contain_package('python-setuptools') } expected that the catalogue would contain Package[python-setuptools]

Check failure on line 22 in spec/classes/python_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

python on archlinux-6-x86_64 with defaults is expected to contain Package[python-setuptools] Failure/Error: it { is_expected.to contain_package('python-setuptools') } expected that the catalogue would contain Package[python-setuptools]
else
it { is_expected.to contain_package('pip') }
it { is_expected.not_to contain_package('python-setuptools') }
end

if %w[Archlinux RedHat].include?(facts[:os]['family'])
Expand Down

0 comments on commit 387fa0d

Please sign in to comment.