From 1f95b858f2ef7ec6cc9c2994327474be8c4cbd5f Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 21 Jan 2025 03:08:24 -0500 Subject: [PATCH] Use --break-system-packages with pip Unfortunately, both versions of `pip` don't have this flag. Check the version, then add the flag if it is not too old. --- tubesync/upgrade_yt-dlp.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh index b92e1fd0..9da6d555 100755 --- a/tubesync/upgrade_yt-dlp.sh +++ b/tubesync/upgrade_yt-dlp.sh @@ -26,5 +26,13 @@ pip3() { warning_message test -n "${TUBESYNC_DEBUG}" || exit 1 -pip3 install --upgrade --break-system-packages yt-dlp +# Use the flag added in 23.0.1, if possible. +# https://github.com/pypa/pip/pull/11780 +break_system_packages='--break-system-packages' +pip_version="$(pip3 --version | awk '$1 = "pip" { print $2; exit; }')" +if [[ "${pip_version}" < "23.0.1" ]]; then + break_system_packages='' +fi + +pip3 install --upgrade ${break_system_packages} yt-dlp