HOWTO use Python 3.11-rc2 under FreeBSD13-stable

Update Python 3.11 is out officially.

You can easily change the version used in the operating system. I highly recommend only having one version of python installed - otherwise it becomes a big mess. To do this, you must first specify in the /etc/make.conf file which version you want to use.

DEFAULT_VERSIONS+=python3=3.11
DEFAULT_VERSIONS+=python=3.11

It is a good idea to clean all packages using the previous version first. I personally do it with a similar script below to find all python 3.10 files in my example.

#!/usr/local/bin/bash
LIST_DEL=""
LIST_INS=""
for FILE in `pkg info | grep py310- | cut -f1 -d' '` ; do
    PKGNAME=`pkg info "$FILE" | grep 'Origin         :' | cut -f2 -d':'` ;
    NEWPKGNAME="${PKGNAME/py310/py311}" ;
    LIST_DEL="$LIST_DEL $FILE";
    LIST_INS="$LIST_INS $NEWPKGNAME";
done
echo "pkg delete -f $LIST_DEL";
echo "\n";
echo "portmaster $LIST_INS";

We save the result of the script execution, preferably in a text file. We run the line starting with "pkg delete -f" from the output.

Then we change the python version to the desired version 3.11 using command like following:

portmaster -o lang/python311 python310-3.10.8 ; portmaster lang/python lang/python3

After execution, you should see something like this:

# pkg info | grep python
python-3.11_3,2                "meta-port" for the default version of Python interpreter
python3-3_3                    Meta-port for the Python interpreter 3.x
python311-3.11.0.r2            Interpreted object-oriented programming language (RC version)

We execute the saved result of executing the script starting with "portmaster". We check with "pkg check -da" for broken packages and possibly recompile them as well.

Issues noted till now:

  1. www/nodejs cannot be updated due to unsupported python version. Even if the Makefile is modified, the resulting version does not work well.
  2. net-im/py-matrix-synapse does not work - at least because of devel/py-frozendict which cannot be compiled.
  3. there are ports that don't want to compile with python3.11 but a simple Makefile edit can change that.