voxpupuli / puppet-python

Puppet module for installing and managing Python, pip, virtualenvs and Gunicorn virtual hosts.
https://forge.puppetlabs.com/puppet/python
Apache License 2.0
199 stars 375 forks source link

Fix python::pip installing $editable VCS packages every Puppet run #491

Closed mlow closed 5 years ago

mlow commented 5 years ago

Pull Request (PR) description

This is due to VCS packages appearing in pip freeze -all as: -e git://example.com/package.git@#egg=

Updates $grep_regex, which checks whether a given version is installed, to match against the two different output formats of pip list. No longer relies on pip freeze.

Additionally, this commit:

Removes the multiple exec resources which were mostly the same and replaces with variables $pip_exec_name, $command, and $unless_command, which get used in a single exec resource at the end of the manifest.

Checks if $pkgname contains ==, and if so splits based on == and sets $real_pkgname to the first part, and $ensure variable to the second part. Uses of $pkgname have been replaced with $real_pkgname.

This Pull Request (PR) fixes the following issues

Fixes #193

bastelfreak commented 5 years ago

Hi @wolttam, thanks for the PR. Can you add an acceptance test to verify that the bug is fixed? Please also have a look at the failed travis jobs.

mlow commented 5 years ago

I fixed what was causing the existing tests to fail -- missing quotes (oops).

And, I added a new test for this, except, here's a quandary... git (or some other vcs, but git seems to be the appropriate choice) is required for it to run. I'm quite unfamiliar with the test framework in use here, so I'm not sure how to make git available. I'm looking into it, though.

bastelfreak commented 5 years ago

this will install git within the docker environment (and improves the formatting):

diff --git a/spec/acceptance/virtualenv_spec.rb b/spec/acceptance/virtualenv_spec.rb
index a3520c3..dbcfd6d 100644
--- a/spec/acceptance/virtualenv_spec.rb
+++ b/spec/acceptance/virtualenv_spec.rb
@@ -113,21 +113,22 @@ describe 'python class' do
     end
     it 'works with editable=>true' do
       pp = <<-EOS
-      class { 'python' :
+      package{'git':
+        ensure => 'present',
+      }
+      -> class { 'python' :
         version    => 'system',
         pip        => 'present',
         virtualenv => 'present',
       }
-      ->
-      python::virtualenv { 'venv' :
+      -> python::virtualenv { 'venv' :
         ensure     => 'present',
         systempkgs => false,
         venv_dir   => '/opt/venv5',
         owner      => 'root',
         group      => 'root',
       }
-      ->
-      python::pip { 'rpyc' :
+      -> python::pip { 'rpyc' :
         ensure     => '4.1.0',
         url        => 'git+https://github.com/tomerfiliba/rpyc.git',
         editable   => true,
mlow commented 5 years ago

this will install git within the docker environment (and improves the formatting): ....

Of course! Added that, pushing now.

bastelfreak commented 5 years ago

Thanks for the awesome work!