Skip to content

Instantly share code, notes, and snippets.

@essandess
Last active March 30, 2021 10:38
Show Gist options
  • Save essandess/29067dc7b50536aa0a1f9f34fece73a7 to your computer and use it in GitHub Desktop.
Save essandess/29067dc7b50536aa0a1f9f34fece73a7 to your computer and use it in GitHub Desktop.
Update MacPorts Python Packages

Install all packages from the previous version

export OLDV=38 NEWV=39
sudo -E port -pNc install "python${NEWV}" $(port -qv installed | egrep -e "^\s*py${OLDV}" | perl -ane 'chomp; $_ = $F[0]; s/py'${OLDV}'/py'${NEWV}'/; print $_, " ";')

port select changes

port select --summary | perl -lane '$_=$F[1]; $myset=join(" ", @F[0,1]); $myset =~ s/'${OLDV}'/'${NEWV}'/; /'${OLDV}'/ && print $myset;' | while read line; do sudo port select --set $line; done

Uninstall the old packages

sudo port -pNc uninstall $(port -qv installed | egrep -e "^\s*py${OLDV}" | perl -ane 'chomp; $_ = $F[0]; print $_, " ";')
unset OLDV NEWV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment