crops / yocto-dockerfiles

This repository is for -base and -builder containers for building derivative containers (such as poky-container) for containerized Yocto Project builds.
GNU General Public License v2.0
145 stars 57 forks source link

Use system package for virtualenv on Debian-based systems #99

Closed robwoolley closed 5 months ago

robwoolley commented 6 months ago

As of Debian 12, running pip3 install virtualenv will give the error: error: externally-managed-environment

It recommends using apt to install system-wide packages instead of pip3. This only affects virtualenv as it is the only Python module installed with pip3 outside of a virtual environment.

All recent Debian and Ubuntu releases seem to have python3-virtualenv packaged so we can just add it to the package list installed by apt.

I did not check the other distros, however I took the approach of making the install command customizable per distro to preserve the current behaviour and provide a means to selectively migrate each distro to using the distro package management.

Signed-off-by: Rob Woolley rob.woolley@windriver.com

moto-timo commented 6 months ago

There is a goal to try to make all the distros behave as similarly as possible. This is why all of them used pip to install virtualenv up to now. Debian 12 is the first distro to use the newish "externally-managed" twist. IMHO, we should investigate installing virtualenv from distro package feeds for all the distros. Not sure what possible side effects there might be.

I'll also point out that the original reason for virtualenv was for testing only and not intended to be used in the resulting docker container. We were trying to keep the containers as small as reasonably possible. Given the speed of development of modern python, it is much more likely that someone will need to install additional python modules for their given development/CI workflow. So just like having pip installed in the containers became highly desirable, it is also likely time to add virtualenv to all the containers.