Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If user declares their requirements.txt in Puppet, don't skip pip installation in python::requirements #619

Merged
merged 11 commits into from
Sep 20, 2023
Merged
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ Alias of `Enum['debug', 'info', 'warning', 'error', 'critical']`

Match all valid package ensures for python

Alias of `Enum['absent', 'present', 'latest']`
Alias of `Enum['absent', 'present', 'installed', 'latest']`

### <a name="Python--Provider"></a>`Python::Provider`

Expand Down
2 changes: 2 additions & 0 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
content => '# Puppet will install and/or update pip packages listed here',
}

$local_subscribe = File[$requirements]
} elsif File[$requirements] and $manage_requirements == true {
$local_subscribe = File[$requirements]
} else {
$local_subscribe = undef
Expand Down
26 changes: 26 additions & 0 deletions spec/acceptance/declared_requirements_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'requirements' do
it 'checks declared requirements file is installed to venv' do
pp = <<-EOS
file { '/tmp/requirements.txt':
ensure => 'present',
content => 'requests',
}

python::pyvenv { '/tmp/pyvenv':
ensure => 'present',
}

python::requirements { '/tmp/requirements.txt':
virtualenv => '/tmp/pyvenv'
}
EOS

apply_manifest(pp, catch_failures: true)

expect(shell('/tmp/pyvenv/bin/pip3 list --no-index | grep requests').stdout).to match(%r{requests +\d+.\d+.\d+})
end
end
2 changes: 1 addition & 1 deletion types/package/ensure.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @summary Match all valid package ensures for python
#
type Python::Package::Ensure = Enum['absent', 'present', 'latest']
type Python::Package::Ensure = Enum['absent', 'present', 'installed', 'latest']