Closed AidanNelson closed 4 months ago
Welcome, @AidanNelson ! Good to hear from you. How have you been?
We are happy you are having a good experience with py5 and that you like the docs.
You didn't mention py5's PyInstaller docs. Did you read them? If not, they will help here. It seems like the jar files are either not included in the pyinstaller package or somehow the classpath is not including them.
I recommend packaging your Sketch into one directory first, before attempting to package it into a single executable file. Putting it in one directory will make it easier for you to debug and validate that the jar files are being included in the correct place. If you can get the package to work correctly for one directory, you will have solved all the py5-related problems and should have no trouble getting it to work in a single executable file.
The py5installer documentation isn't perfect. I think there are some Windows problems... @villares, that was your experience, right? If you can suggest ways to improve, please let us know!
Also, you know this is Jim, right? from ITP? We know each other IRL :)
Hi Jim!
Yes, I knew it was you.
I was glad to see your recent update about the gallery show. Congratulations! 🎉
I've been well. Learning a bit of python has been a fun recent expedition. Would love to catch up properly one of these days.
Thanks for sending those docs. I hadn't seen those yet. I'll look them over and report back.
Hope all is well, Aidan
I was glad to see your recent update about the gallery show. Congratulations! tada
Thank you!
I've been well. Learning a bit of python has been a fun recent expedition. Would love to catch up properly one of these days.
Great, glad you are doing well! Python is a fun language and I hope py5 makes it easy to learn. Are you looking at the introduction to py5 tutorials?
Thanks for sending those docs. I hadn't seen those yet. I'll look them over and report back.
I think they will be useful, even though they aren't perfect. If in your experiments you learn anything new about Py5Installer and py5, please make a PR to improve that page!
Just did a bit of troubleshooting and found a few things (that may be somewhat specific to my system). I'll include them here in case anyone runs into these problems.
I had two versions of the Java JDK. One had been installed in the standard location and was version 12. Another was installed using homebrew and was version 20. In order to fix the PyInstaller build, I had to include the correct version (from homebrew). For me, this meant including the following line in my pyInstaller spec file: datas += [('/usr/local/Cellar/openjdk/20.0.1/libexec/openjdk.jdk', 'JAVA_HOME')]
For some reason, I kept getting an error when using binaries += collect_dynamic_libs('py5')
which seemed like it was trying to run the linux binary. Only including the Mac OS binaries with binaries += filter(lambda x: x[1].split('/')[2] in ["macos-x86_64"], collect_dynamic_libs('py5'))
fixed this.
Other than that, things seemed to work smoothly!
And I'm jumping all around the reference. One feature that was particularly helpful for my application (which uses opencv-python) was the ability to generate a py5 image from a numpy array.
@AidanNelson , I'm glad you have it working, and thanks for reporting back with what you figured out.
I read what you wrote and looked at the documentation. It seems there are two improvements we could make:
Do you think both of those changes would address the challenges you faced?
And I'm jumping all around the reference. One feature that was particularly helpful for my application (which uses opencv-python) was the ability to generate a py5 image from a numpy array.
Excellent! That is a useful feature. The numpy stuff was added to py5 early in its development.
If you like, I am happy to meet with you over Zoom to do a code review of your project. I might be able to point out other py5 features that will be useful to you.
@hx2A
Re: the JRE, I think it was pulling JRE v.12. That said, I was a bit confused because homebrew had installed (but not linked) v.20, and I thought I was using v.20.
And I'm also surprised that it was trying to use the incorrect binary. No, I have a good old-fashioned Intel Mac.
The documentation was very helpful in both cases.
And thanks for offering about a code review. I may take you up on that once the project is a bit further along! I'm using multi-threading and passing images from another thread to py5 and there are some performance issues I'm trying to resolve at the moment.🙏
And thanks for offering about a code review. I may take you up on that once the project is a bit further along! I'm using multi-threading and passing images from another thread to py5 and there are some performance issues I'm trying to resolve at the moment.
Using multi-threading and images with py5 is something I have a lot of experience with. I can definitely help out with that when you are ready. Just let me know
Cheers, @AidanNelson and @hx2A, I wonder if you clever people who managed to make a PyInstaller bundle couldn't provide some sort of "template project" one could download, fiddle with, and "build"?
Could this project contain a Python interpreter one could pip or conda install additional packages to? I suppose we would have to have different templates for different platforms?
Does this idea make any sense?
PS: As Jim mentioned, I tried it on Windows a long time ago and I vaguely remember mixed results (like, it worked on one machine, but not in another) and I've been too unfocused to try anything that requires more than 3 neurons cooperating lately...
Sorry for the late reply...
Haven't had any time to work with PyInstaller. There is the documentation page (https://py5coding.org/how_tos/pyinstaller.html) but you know about that and it is not perfect. It might work better on Linux, since I do most of my work there. Perhaps we can try to get a working template for linux, then figure out how to get it to work for the other platforms?
Hi @villares and @hx2A, I did manage to get my project to build using pyInstaller, though I never quite figured out all of the kinks of building to Windows (I was developing on Mac for use on Windows).
Where do you think something like this should live? In the py5 examples repo?
Oh, thanks folks!
Yes, let's try something minimal and grow slowly from it... Yes, I think the py5 examples repo would be a nice place to keep it!
Thank you, @AidanNelson ! Can you also point out the deltas between what you learned about packaging and what is written on https://py5coding.org/how_tos/pyinstaller.html?
I think I didn't remember the gist with the example files & spec file... I'll try it again, it might be just the kind of template I was thinking.
Do you think we can close this @AidanNelson ? :)
Off topic: As you mentioned you are on MacOS, wouldn't you like to help us make some Thonny IDE Mac packages with py5 + JDK pre-installed?
I'm going to close this. Feel free to re-open it if you wish, @AidanNelson !
Hi @hx2A and all!
I'm so glad to be trying out py5. The docs are fantastic and my experience has been great so far.
I ran into a bit of an issue when trying to use pyInstaller to bundle my python / py5 script into executable file. The app bundled without error, but displayed the following error when trying to run the app:
I am on a Mac OS 13.1 System.
Are there any workarounds you know or best practices for bundling an app with py5?
Thanks, Aidan