Reputation: 109
I have written some bunch of python files and i want to make a window application from that. The structure looks like this: Say, a.py,b.py,c.py are there. a.by is the file which i want application to open and it is basically a GUI which has import commands for "b.py" and "c.py". I know this might be a very basic problem,but i have just started to packaging and deployment using python.Please tell me how to do that , or if is there any way to do it by py2exe and pyinstaller?
I have tried to do it by py2exe and pyinstaller from the info available on internet , but that seems to create the app which is running only "a.py" .It is not able to then use "b" and "c " as well.
Upvotes: 0
Views: 2078
Reputation: 2657
zipapp
Assuming this is your project tree,
<root_folder>
| - a.py
| - b.py
| - c.py
you can rename a.py
to __main__.py
and then call from bash/cmd python -m zipapp <root_folder>
in order to create a <root_folder>.pyz
file.
This file is executable both with Windows and UNIX systems, and will package every module that lies inside your <root_folder>
.
If you need to include libraries too, you have to call python -m pip install <libs> --target <root_folder>
and, after, you call zipapp
like shown above.
This is the documentation of zipapp
.
zipfile
Since Python 2.6, you can create a zip file containing all your files (and __main__.py
too, cause it's your entry point) and then run it in console launching
python <zip_name>.zip
Pay attention: your zip has to be structured like this
<zip_name>.zip
| - __main__.py
| - b.py
| - c.py
Upvotes: 1
Reputation: 216
I am not sure on how you do this with py2exe. I have used py2app before which is very similar, but it is for Mac applications. For Mac there is a way to view the contents of the application. In here you can add the files you want into the resources folder (where you would put your 'b.py' and 'c.py').
I hope there is something like this in Windows and hope it helps.
Upvotes: 0