diff --git a/REFERENCE.md b/REFERENCE.md index f3a382e5..fbfb0a48 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -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) @@ -217,6 +218,14 @@ manage the state for package pip Default value: `$python::params::manage_pip_package` +##### `manage_setuptools` + +Data type: `Boolean` + +if true, install python-setuptools + +Default value: `$facts['os']['family'] ? { 'Archlinux' => true, default => false` + ##### `venv` Data type: `Python::Package::Ensure` diff --git a/manifests/init.pp b/manifests/init.pp index b457edbd..24bf08e4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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': @@ -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} -- ", diff --git a/manifests/install.pp b/manifests/install.pp index c3db3d80..28885d3a 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -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, diff --git a/manifests/pyvenv.pp b/manifests/pyvenv.pp index 5bfc2103..db7c6468 100644 --- a/manifests/pyvenv.pp +++ b/manifests/pyvenv.pp @@ -94,14 +94,14 @@ } exec { "python_virtualenv_${venv_dir}": - command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} --log ${venv_dir}/pip.log install ${pip_upgrade} && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade setuptools", + command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} --log ${venv_dir}/pip.log install ${pip_upgrade} && cat ${venv_dir}/pip.log && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade setuptools && cat ${venv_dir}/pip.log", user => $owner, creates => "${venv_dir}/bin/activate", path => $_path, cwd => '/tmp', environment => $environment, timeout => 600, - unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate && cat ${venv_dir}/pip.log", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv require => File[$venv_dir], } } elsif $ensure == 'absent' { diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index 54c47fc7..bb787a58 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -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') } 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'])