There is no specific reason why you shouldn’t be able to do that with dispatch. It is just a bash script, just like they would be doing with install and install.real. dispatch should be able to do exactly what you want, and then invoke src/charm.py.
I’d rather just figure out why test-and-install isn’t allowing src/charm.py to be executed. There are several options, like doing:
exec $PYTHON3 src/charm.py
rather than just ‘exec src/charm.py’
That leaves bash and dispatch to find the PYTHON to use, rather than ‘/usr/bin/env’ in case there is some sort of problem there.
Bundling the python executable itself is possible, though we’ve looked into it a bit, and you run into problems with dynamic libraries. (Even if you make python itself statically compiled, you almost always still depend on libc and RedHat’s libc is different from Ubuntu, vs different versions of Ubuntu, etc.)
Though as I understand it, you can statically link against libc (AIUI the Juju binaries do).
It is possible to bundle, but realize that it does add its own overhead (larger charm binaries, larger attack surface, more to update when, eg, and SSL vulnerability is found, etc.) Distro’s already solve most of the security issues of keeping packages up to date, so leveraging them for that is usually wise.