set AZ_INSTALLER to DEB The AZ_INSTALLER variable influences the az upgrade command behaviour. For the packaged version, we want it to simply run apt update/upgrade, so always set it to DEB.
{az} use runpy instead of os.execl python -m adds the current working directory to the start of sys.path, which means running from say /tmp with a fake azure.py causes az to load it and run it.