From 32a1c9e1ac158f70223a125af06beaaadb2e87ac Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Mon, 14 Nov 2022 08:49:19 +0000 Subject: [PATCH 1/2] pip_library: test for presence of --system option before invoking pip (#82) The version of pip provided by `python3-pip` in Debian 12 will drop the custom `--system` option - passing it results in pip exiting with an error. Rather than always passing `--system` if the host OS is Debian-like, test whether the configured pip tool implements a `--system` option, and if so, pass it to the real pip invocation. Fixes #81. --- build_defs/python.build_defs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/build_defs/python.build_defs b/build_defs/python.build_defs index a961a79d..e71f6cea 100644 --- a/build_defs/python.build_defs +++ b/build_defs/python.build_defs @@ -424,10 +424,18 @@ def pip_library(name:str, version:str, hashes:list=None, package_name:str=None, # Unfortunately it does *not* work similarly on the Debian problem :( pip_cmd = 'echo "[install]\nprefix=" > setup.cfg; ' + pip_cmd if CONFIG.OS == 'linux' and CONFIG.PYTHON.DISABLE_VENDOR_FLAGS == "false": - # Fix for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830892 - # tl;dr: Debian has broken --target with a custom patch, the only way to fix is to pass --system - # which is itself Debian-specific, so we need to find if we're running on Debian. AAAAARGGGHHHH... - pip_cmd = f'[ -f /etc/debian_version ] && SYS_FLAG="--system" || SYS_FLAG=""; {pip_cmd} $SYS_FLAG' + # Workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830892 + # + # Version 8.1.2-1 of Debian's python3-pip package inverts pip's standard behaviour: --user becomes the default; + # a Debian-specific --system option reverts to upstream pip's default behaviour, and it must be passed in order + # to use the --target option. python3-pip 18.1-1 changes the behaviour again, implying --user only if --target + # is not passed and therefore removing the need to pass --system (although it can still be passed to guarantee + # upstream pip's behaviour). python3-pip 21.3.1-1 drops the --system option altogether, and passing it causes + # pip to exit with an error). + # + # The easiest way to deal with this mess is to test whether the pip_tool we're using implements --system, then + # to pass it in the real pip invocation if so. + pip_cmd = f'[ -f /etc/debian_version ] && {pip_tool} --system >/dev/null 2>&1 && SYS_FLAG="--system" || SYS_FLAG=""; {pip_cmd} $SYS_FLAG' pip_cmd += f' {repo_flag} {index_flag} {pip_flags} {package_name}' From 2bb29a21c9b1d04e460e2fdcae19d6002d705d06 Mon Sep 17 00:00:00 2001 From: Jon Poole Date: Wed, 18 Jan 2023 11:45:50 +0000 Subject: [PATCH 2/2] Tag v2 beta so this is less confusing --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ee6cdce3..6060c31a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.1 +2.0.0-beta.1