Is it possible to execute package wrapped into archive as module
09:25 03 Jun 2024

This is the structure:

__init__.py
__main__.py
server.py

Inside __main__.py I use relative imports:

from .server import app

When I zip the directory:

python -m zipapp app_builder

And then try to run it like this I get the error:

python app_builder.pyz

ImportError: attempted relative import with no known parent package

which is expected. I need a way to run the code inside the archive similar to this:

python -m app_builder

which works fine.

python zipapp