This is exactly how I package my python scripts. The answer to your question: Memfd
https://magisterquis.github.io/2018/03/31/in-memory-only-elf...
And zipimport pip package
And zipimport pip package
Same thing for java, dart, etc. This makes it much easier to deploy, use, download, as it's basically "zero"-config install, no need for scripts to tweak your PATH, etc.
(but it has limitations clearly, if you use proprietary code, or you can't compile given open source library bundled with you - e.g. LGPL code, that you have to dynamically link, then again if you are project is open source this is no longer that much of a limit (but would not know that for sure))