Take your libtk8.6.dylib and stuff it.
April 7, 2014 4:33 PM   Subscribe

The headache of distributing python GUI-based applications has finally driven me to consider switching to another language. Is Java a good alternative for ulcer-free distribution of GUI-based applications?

This paragraph is a rant - it is helpful, but not essential to understanding my question:
I love python. I've loved python for 8 years. I've used many other languages, but python is the one that I became a "real" programmer in, i.e. a programmer who writes programs that other people actually want to use. Now I want out. Over the last 2 years I've developed a large scientific analysis GUI with Tkinter that several other people have used. I tore my hair out trying to make an app bundle so I could distribute it. I think I spent about as much time trying to bundle it as I did developing it in the first place. It was hell. I'm sure an expert in Tk/Tcl/bundling could have done it, but I never really got it to work consistently. The app bundles I made weren't portable to another mac, even one running the same OS as me, despite the gracious help of more experienced python users. I recognize that I *could* make it work if I kept trying things, but it's not worth it to me at this point, and I don't have enough confidence that if I solved the issues with this project, I wouldn't run into a whole new set of issues with the next.

My question: If I switched to writing in Java, would I be able to write an executable GUI that just *works* on another computer (dare I hope, even one running a different version of OS X), without extensive jiggering with external dependencies, fussing with Mach-O tools, or other headachey things? Or will I have to deal with problems like this no matter what language I'm writing in? Is there a better option? I already have basic fluency in Java, but I've never written a GUI that I tried to distribute to others.

Thanks.
posted by Salvor Hardin to Technology (10 answers total) 5 users marked this as a favorite
 
Have you posted this question to your local Python user group listserv yet?
posted by oceanjesse at 4:42 PM on April 7, 2014 [1 favorite]


Don't use Java, write a real Mac app in objective C.
posted by w0mbat at 4:53 PM on April 7, 2014 [6 favorites]


Short answer: yes. You save it as a .jar and anyone with a JRE (that is, "with Java installed") will be able to run your program, with the caveat that their JRE major version (1.7, 1.8) should be at least as high as the version of Java you use to write the program.

It won't be as pretty as using Objective C, and there are some hurdles in learning how to build the interface with Swing, which is pretty archaic, but you shouldn't have the issues you're experiencing now. Maybe there's a better way of distributing your Python app, but that's another question.
posted by The Michael The at 4:58 PM on April 7, 2014


I don't know many people distributing using OSX bundles. If you want to target a random Python user, it's best to give them instructions on how to install you package via Pip. Expand with instructions or a link on how to install Pip on OSX if you feel your users will need it. Consider making a web app; IPython notebooks are usable from a web browser with zero installation on the client side. If this is data analysis someone will still need to install the notebook server where the data is, but it can be shared with other people in the lab.

With java, you can ship a jar that will work probably if people already have java installed (a sufficiently recent java, plus any system libraries your dependencies pull) and if you take care to bundle the requirements with the jar.
posted by Tobu at 5:06 PM on April 7, 2014 [1 favorite]


So as a user, my first reaction is "Java's going to somehow make things easier? Riiiiight".

I'm seeing VMs with older versions of Java (that have all of the security holes) because apps won't run on newer versions, and...

Yeah. There are a bunch of different ways to package Python for distribution, up to and including embedding the Python interpreter in a C/C++/Objective-C app, no? I'd seriously dig deeper into that space.
posted by straw at 5:09 PM on April 7, 2014


Also, standard advice when building packages and bundling libraries: build on a really old system, so that the libraries you bundle will work on old systems as well as newer ones. However, I'm happy ignoring binary distributions most of the time; source dists are multiplatfom and who installs them where is not necessarily your problem, other people can build binary packages if they like (like Anaconda and Enthought).
posted by Tobu at 5:31 PM on April 7, 2014


It depends on what your cross platform support goals are. Mac only or genuinely cross platform?

Java GUI's can be a painful learning curve for someone coming from the clarity of Python.

I've done Ruby distributable apps that didn't require anything of the system they were installed on.
posted by srboisvert at 6:03 PM on April 7, 2014


Please don't use Objective-C, write a portable app in Java. See Fiji as an example of how it can be done. Believe it or not there are scientists who don't use Macs.
posted by Poldo at 6:03 AM on April 8, 2014


Response by poster: Thanks for the suggestions folks. At the moment, I'd at least like to be able to write code that works on multiple Macs, though it would be pretty swell if it worked in Windows without too much hassle too.

This whole process really humbled me - I ran into so many problems that I couldn't solve. It really soured me on programming in general, as silly as that sounds. I think I went in with unrealistic expectations about how well Tkinter, Tk/Tcl, py2app, etc would play together.

If I may tack on an extra question, can anyone tell me how to get better at this kind of thing? I did a lot of reading and fiddling with dylibs and external libraries from macports and non-macports and library dependencies and versions and different packaging software...and I feel like I'm as much a noob as when I started.

PS: Poldo, it's really funny that you mention Fiji. The program that nearly killed me trying to distribute it was inspired by ImageJ, or rather by the limitations of ImageJ for a particular scientific purpose.
posted by Salvor Hardin at 6:14 PM on April 9, 2014


I don't really know much about Tkinter and haven't used Macs, but I've made a program a while ago using python, wxPython and py2exe which I had no issues distributing to windows and unix users, using simple setup.py for unix. So perhaps your issues are with Tkinter-on-Mac, not with Python. wxPython is harder than Tkinter but it's got more features.

My experience is from 6-7 years ago, so things are probably easier and better now. My app, coincidentally, was called Tobu, unrelated to the user by the same name who gave some good answers on this thread!
posted by rainy at 9:50 AM on April 11, 2014


« Older Are you an expert on 1950s Scandinavian lounge...   |   Books & Resources on Letting Go Newer »
This thread is closed to new comments.