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 371 forks source link

pyvenv is no longer compatible with Python built from source #540

Open chrisjbremner opened 4 years ago

chrisjbremner commented 4 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

  ::python::pyvenv { $venv_path :
    version => '3.7.6',
  }

What are you seeing

The virtualenv is not created because it cannot install the python3.7-venv package via apt. This is because my version of python3.7 was built from source, and therefore I didn't get the python3.7 package via apt. Since python3.7 is required to install python3.7-venv via apt, this fails.

When built from source, venv is already included, so an additional package containing the venv module is not necessary, so this step should be skipped.

What behaviour did you expect instead

I expected the virtualenv to be correctly created

Output log

Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install python3.7-venv' returned 100:
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python3.7-venv
E: Couldn't find any package by glob 'python3.7-venv'
E: Couldn't find any package by regex 'python3.7-venv'

Any additional information you'd like to impart

I believe that the best way to skip this step if necessary would be to check for the presence of the venv module. This could either be done using something like python3.7 -c "import venv" or pydoc3.7 venv, or checking if the folder exists at /usr/local/lib/python3.7/venv (not sure if this directory changes).