Skip to content

Instantly share code, notes, and snippets.

@noromanba
Last active January 12, 2023 20:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noromanba/d2b7472bc8cba64f8b98c0069826764d to your computer and use it in GitHub Desktop.
Save noromanba/d2b7472bc8cba64f8b98c0069826764d to your computer and use it in GitHub Desktop.
pseudo `pip-upgrade`
#!/usr/bin/env bash
# pseudo `pip upgrade`
# @version 2022.12.12.1
# @license CC0 Univ PD https://creativecommons.org/publicdomain/zero/1.0/
# @author noromanba https://noromanba.github.io
set -eCx
# always backup
requirements=~/requirements.txt
pip freeze | tee "$requirements"
# pseudo pip-upgrade
# short option for BusyBox e.g. Termux
# upgrade
pip list | \
# --lines='+3'
tail -n '+3' | \
# [^1] pip 22.0+ notice truncate
sed '/^\s*$/,$d' | \
# --fields=1 --delimiter=' '
cut -f 1 -d ' ' | \
# prevent updates
#sed 's/<PACKAGE_NAME>//'| \
xargs pip install --upgrade
# DEV
# [^1]: `pip list` annoying notice put to *stdout* if not installed latest pip package from v22+, notice only pip
#
# ```
# $ pip list
# Package Version
# -------------- ----------
# pip 22.2
# setuptools 63.3.0
#
# [notice] A new release of pip available: 22.2 -> 22.2.1
# [notice] To update, run: pip install --upgrade pip
# $
# ```
#
# WTH
# after install latest pip
#
# ```
# $ pip list
# Package Version
# -------------- ----------
# pip 22.2.1
# setuptools 63.3.0
# $
# ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment