I have recently switched on some of my machines to FreeBSD.
I have also adjusted my "make your life easier" scripts to work on FreeBSD.
Some of them are written in Python, and I am looking for a way to write shebangs in such a way that they work on Linux and FreeBSD just by calling the script.
On Ubuntu, there is always
Moreover, this symlink is automatically managed by the system, so it always points to the installed version of Python3.
My shebangs so far looked like this:
However, on FreeBSD there is no
There is only a binary with a name containing a particular version of Python, for example,
Of course, I can manually create the symlink.
However, it will break in case of Python update, for example, for version 3.12, the new Python binary will be named
I wonder if someone has a better way for handling portable shebangs for Python scripts.
I have also adjusted my "make your life easier" scripts to work on FreeBSD.
Some of them are written in Python, and I am looking for a way to write shebangs in such a way that they work on Linux and FreeBSD just by calling the script.
On Ubuntu, there is always
python3
symlink in the /usr/bin/
to the installed version of Python3.Moreover, this symlink is automatically managed by the system, so it always points to the installed version of Python3.
My shebangs so far looked like this:
/usr/bin/env python3
.However, on FreeBSD there is no
python3
symlink in /usr/local/bin/
.There is only a binary with a name containing a particular version of Python, for example,
python3.11
.Of course, I can manually create the symlink.
However, it will break in case of Python update, for example, for version 3.12, the new Python binary will be named
python3.12
.I wonder if someone has a better way for handling portable shebangs for Python scripts.