Always add --break-system-packages to pip when the Docker context is active.

This fixes the case where Platydock is called within the context of a
virtual environment, but it needs to generate a Docker image - and
therefore, unless the host virtual environment, it needs
--break-system-packages to write to /usr.
This commit is contained in:
Fabio Manganiello 2024-05-25 10:28:57 +02:00
parent 5e52741986
commit 05c6449d8b
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -453,19 +453,22 @@ class Dependencies:
(as a single string) or the list of packages that will be installed (as a single string) or the list of packages that will be installed
through another script. through another script.
""" """
wants_break_system_packages = not ( wants_break_system_packages = (
# --break-system-packages has been introduced in Python 3.10 # --break-system-packages has been introduced in Python 3.10
sys.version_info < (3, 11) sys.version_info >= (3, 11)
# If we're generating a Docker image then we always need
# --break-system-packages
or self._is_docker
# If we're in a virtual environment then we don't need # If we're in a virtual environment then we don't need
# --break-system-packages # --break-system-packages
or self._is_venv or not self._is_venv
) )
if self.pip: if self.pip:
deps = sorted(self.pip) deps = sorted(self.pip)
if full_command: if full_command:
yield ( yield (
'pip install --no-input ' 'pip install -U --no-input '
+ ('--no-cache-dir ' if self._is_docker else '') + ('--no-cache-dir ' if self._is_docker else '')
+ ( + (
'--break-system-packages ' '--break-system-packages '