-
-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2549 feat: added build package script #2789
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the pull request, @gotev!
I just reviewed the code and refactored it a bit to organize common and platform-specific arguments more intuitively. And I introduced argparse to allow configuring the parameters from outside.
What do you think so far?
I wonder if we really need to call pyinstaller
without python -m
on Windows... And what's the reason for the extra --onedir
? There might already be an explanation in one of the issues and discussions, but I honestly lost track of every detail. Good to have this script to capture them all! 🙂
Great @falkoschindler ! Now I understood your idea better. I thought we wanted to give a basic build script from which to start for our users, but you intend to completely wrap PyInstaller. Some considerations and questions which came to mind:
Then, regarding the updated PR:
|
@gotev You're right, we should be careful not to suggest or promise to wrap PyInstaller in all its glory, but to only give a starting point from which our users can deviate. I just thought it would be nice to have an executable documentation for how to package a NiceGUI app that is actually shipped with the library and which you can simply call for simple use cases. (In the future) we can use it to guide the user to the most important arguments to consider and include some hints, either in the help text or in form of console output, like "1. Make sure to set native=True...", "2. Note about packaging on macOS: ..." and so on. Regarding the $ ./pack.py --add-data /foo --add-data /bar --dry-run main.py
python -m PyInstaller --name Your App Name --add-data /Users/falko/Projects/nicegui/nicegui --add-data /foo --add-data /bar --windowed main.py |
Got it, so let's proceed then. If we have a way to validate what the user is passing in Another useful thing we could add is to print out the full PyInstaller command before executing it, so it's clear we're providing a helper rather than a wrapper, reducing frictions for simple use cases and already giving the starting command for more complex scenarios. In this case I'd always print out the command and then terminate the script before executing it if dry run option is passed. |
I like the idea of always printing the command! |
Agreed! As an idea to achieve that, we could detect if the app is running inside a pyinstaller package at runtime: import sys
def is_pyinstaller():
return getattr(sys, 'frozen', False) or hasattr(sys, '_MEIPASS') and validate run params. But that's for another PR 😉 |
# Conflicts: # pyproject.toml
I just looked into this PR and noticed some remaining points we need to address:
|
Ok, I added some more documentation to the pack.py script. Let's merge and improve it later. |
@falkoschindler added the script as per your instructions in #2549. The script is meant to be copied and used as a base package build script for nicegui users, who will need to also modify it for their own specific usage (e.g. adding resources, icons and so on)