Skip to content

Instantly share code, notes, and snippets.

@noromanba
Last active September 2, 2026 16:50
Show Gist options
  • Select an option

  • Save noromanba/d2b7472bc8cba64f8b98c0069826764d to your computer and use it in GitHub Desktop.

Select an option

Save noromanba/d2b7472bc8cba64f8b98c0069826764d to your computer and use it in GitHub Desktop.
pseudo `pip-upgrade`
#!/usr/bin/env bash
# pseudo `pip upgrade`
# @version 2026.6.5.6
# @license CC0 Univ PD https://creativecommons.org/publicdomain/zero/1.0/
# @author noromanba https://noromanba.github.io
# @homepage https://gist.github.com/noromanba/d2b7472bc8cba64f8b98c0069826764d
set -o errexit
set -o nounset
set -o pipefail
#set -o xtrace
# require uv
# [1] avoid `uv pip freeze` and python-pip
#:<<'ENSURE_WHOLE'
uv pip list --format freeze |
cut --delimiter='=' --fields=1 |
sed '/^pip$/d' |
xargs --no-run-if-empty uv pip install --upgrade
#ENSURE_WHOLE
# [2] DO NOT USE `--outdated`
# `uv pip install --upgrade`; reverse dependencies are not resolved as roots
:<<'FIXME_TARGETED'
uv pip list --format json --outdated |
python -c '
import json, sys
for pkg in json.load(sys.stdin):
if pkg["name"] != "pip":
print(pkg["name"])
' |
#jq --raw-output '.[] | select(.name != "pip") | .name' |
xargs --no-run-if-empty uv pip install --upgrade
FIXME_TARGETED
# --prerelease allow /nightly
#uv pip install --upgrade --pre \
# '<PACKAGE_NAME>'
# ensure depends
uv pip check
# [^1] `uv pip freeze` may emit unexpected output for some `python-*` packages
#
# e.g. Termux python-pip
#
# $ uv pip freeze
# pip @ file:///home/builder/.termux-build/python-pip/src
#
# because it may emit local build paths or other unexpected metadata
#
# if you wat to use `pip`, must be use env patched `python-pip` via package mamager
# [^2] `[uv] pip install --upgrade` does not lookup rdpends
# e.g. `gtts` and `click`
#
# 1. use `--outdated`
# $ uv pip list --format json --outdated
# Using Python 3.14.6 environment at: /data/data/com.termux/files/usr
# [{"name":"click","version":"8.1.8","latest_version":"8.5.0","latest_filetype":"wheel"}]
#
# 2. `upgrade`
# $ uv pip install --upgrade click
#
# 3. break the depends
# $ uv pip check
# Found 1 incompatibility
#
# The package `gtts` requires `click>=7.1,<8.2`,
# but `8.5.0` is installed
#
# 4. actually
# $ uv pip tree --show-version-specifiers # --invert --package {PACKAGE_NAME}
# gtts v2.5.4
# ├── click v8.1.8 [required: >=7.1, <8.2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment