Skip to content
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

Nuitka stand alone executables #296

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open

Nuitka stand alone executables #296

wants to merge 15 commits into from

Conversation

JTvD
Copy link
Collaborator

@JTvD JTvD commented Dec 24, 2024

It is unfortunate that when the ‘--onefile’ flag is passed to a python package the executable is first unpacked into a temporary directory before it is started. Therefore I recommend to build the executable as a folder. One big advantage of Nuitka over pyinstaller is that it compiles the python code to C where possible. In my tests on Windows this executable is 5x faster than the one build by pyinstaller. The price to pay is some compilation time, sounds like a good trade to me.

There is some weird behavior, when building the executable the first time I got the error '"irods_authentication_scheme": "irods.auth.pam_password" does not exist'.
To solve this I forced nuitka to include the entire python irods package (minus the test folder) in the build:
"--include-package=irods --nofollow-import-to=irods.test"
With this change all functionalities work. It is not clear to me why this specific import is not followed by default.

Additional changes:

  • At the end of the build script the naming is updated to translate 'main/__main.exe' into 'ibridgesgui/ibridgesgui.exe'
  • Added a script to convert the '.ui' files into '.py' files
  • Updated the references to the 'LOGO_DIR' in both the gui_utils.py as the '.py' ui files. This simplifies the folder tree
    • From: folder with exe > ibridgesgui/icons/*.png
    • To: folder with exe > icons/*.png

The code has been tested on IOS and ubuntu but its always recommended to give it a check. The majority of my testing was done on windows in an effort to make iBirdges available on all WUR machines.

@JTvD JTvD requested review from chStaiger and qubixes December 24, 2024 08:45
rmtree(shipping_folder, ignore_errors=True)
shipping_folder.parent.mkdir(parents=True, exist_ok=True)
Path('__main__.dist').rename(shipping_folder)
Path(f'{shipping_folder}/__main__.exe').rename(f'{shipping_folder}/ibridges.exe')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be ibridges-gui.exe? Also, for non-windows, there probably shouldn't be the .exe suffix, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this is why it would be nice to test this on a different OS. Unfortunately I only have headless Ubuntu machines. Also renamed the exe to 'ibridges-gui.exe'.

Copy link
Collaborator

@qubixes qubixes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very nice to be able to create a (fast) executable, thanks for implementing it! I currently don't have a Python/windows setup, but I can if needed test it out later.

It would be nice if the executable is built automatically with every release. That should be possible with github Actions, right?

Btw, the setup with the venv seems rather complicated, but I suppose that's how Nuitka is supposed to work? I was trying to figure it out from their documentation, but it seems a little sparse.

@JTvD
Copy link
Collaborator Author

JTvD commented Jan 10, 2025

In general executables, or installers will make it easier for our users, enabling also people without any python knowledge to get started on their own.

Nuitka is not crossplatform so you have to build the windows exe on a windows machine, ubuntu for ubuntu etc. We might be able to solve this with docker files, starting these with github actions but that's another bridge.
Let's first try to get the toml, pyside6 and this merge request in before we start something new.

The venv has nothing to do with Nuitka, subprocesses don't inherit the venv from the process in which they are started.
Therefore the venv must be activated in each new subprocess, which can be done with a mechanism like this.

@qubixes
Copy link
Collaborator

qubixes commented Jan 10, 2025

Yes, it would be nice to build the executables every release automatically with GH actions, but I agree with you that that can wait. It looks like we're already quite close though (thanks to this PR)! I would say mac / ubuntu is a lower priority, since most users will only have to use pip install, but since the infrastructure is there, we might as well build them.

@JTvD
Copy link
Collaborator Author

JTvD commented Jan 10, 2025

@qubixes is also my preference to build the exe for all three operating systems. I already did some homework, the git actions are described in the documentation of Nuitka: github actions That is an easy setup, personally prefer to have the script to build it locally (this PR) as well so we can debug the builds and test new functionality.

@qubixes
Copy link
Collaborator

qubixes commented Jan 10, 2025

Agreed!

Base automatically changed from pyside6 to develop January 12, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants