From 05c6449d8b2d919a08d4fa54120073dbbd134f9a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 25 May 2024 10:28:57 +0200 Subject: [PATCH] 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. --- platypush/utils/manifest.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platypush/utils/manifest.py b/platypush/utils/manifest.py index c559109168..4ce3a59f59 100644 --- a/platypush/utils/manifest.py +++ b/platypush/utils/manifest.py @@ -453,19 +453,22 @@ class Dependencies: (as a single string) or the list of packages that will be installed through another script. """ - wants_break_system_packages = not ( + wants_break_system_packages = ( # --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 # --break-system-packages - or self._is_venv + or not self._is_venv ) if self.pip: deps = sorted(self.pip) if full_command: yield ( - 'pip install --no-input ' + 'pip install -U --no-input ' + ('--no-cache-dir ' if self._is_docker else '') + ( '--break-system-packages '