Solved How to properly update python from py38 to py39

FreeBSD 12.3 p5.

I'm trying to update Python py38 to py39 using this from the ports UPDATING section ...


20220626:
AFFECTS: users of python
AUTHOR: thierry@FreeBSD.org

The default version of python3 and python was switched to 3.9.

For ports users wanting to keep version 3.8 as default,
add DEFAULT_VERSIONS+= python=3.8 python3=3.8 to make.conf

Following procedures may ease the upgrade:

For users of pre-build packages:
# sh
# for i in $(pkg query -g %n 'py38-*'); do pkg set -yn ${i}:py39-${i#py38-}; d one
# pkg upgrade

For portmaster users:
# sh
# portmaster -o lang/python39 python38
# REINSTALL="$(pkg info -o "*py38*" | awk '{printf "%s ", $2}')"
# pkg delete -f "*py38*"
# portmaster $REINSTALL
# REBUILD=$(pkg query -g "%n:%dn" '*' | grep py3 | grep -v py39 | cut -d : -f 1 | sort -u)
# portmaster $REBUILD
# REBUILD2=$(pkg list | grep python-38 | xargs pkg which | awk '{print $6}' | sort -u)
# portmaster $REBUILD2

Final steps (for pre-built packages & portmaster):

If no longer required, Python 3.8 can be removed via
"pkg remove python38" and the directory /usr/local/lib/python3.8 can
then be deleted afterwards, if not empty.

However when I try to run REINSTALL="$(pkg info -o "*py38*" | awk '{printf "%s ", $2}')" I always get the error Illegal variable name..

I'm sure this worked fine from py37 to py38. Any suggestions.
 
It seems I have now inadvertently deleted all the py38 ports. No clue how it occurred but it has.

I've got a list of them in the logs. Is it a simple case of pkg install the py39 flavour now?
 
You forgot the sh and you were running it under csh (likely the result of su-ing to root).
Code:
$ csh
% REINSTALL="$(pkg info -o "*py38*" | awk '{printf "%s ", $2}')"
Illegal variable name.

A more interesting question is how the heck does the quoting work in that statement. Why doesn't sh raise an error over the nested double quotes around "*py38*".
 
Back
Top