I know there is a way to import modules which are in a zip file with python. I created kind of custom python package library in a zip file.
I would like to put as well my “task” script in this package, those are using the library. Then, with bash, I would like to call the desired script in the zip file without extracting the zip.
The goal is to have only one zip to move in a specified folder when I want to run my scripts.
I finally found a way to do this. If I create a zip file, I must create
__main__.pyat the root of the zip. Thus, it is possible to launch the script inside the main and call if from bash with the following command :python myArchive.zipThis command will run the
__main__.pyfile! 🙂Then I can create
.commandfile to launch the script with proper parameters.You can also put some code in the
__main__.pyfile to give you more flexibility if you need to pass arguments for example.ex:
python __main__.py buildProjectThe reference documentation is here: https://docs.python.org/2/library/runpy.html