bundling python with application

Diez B. Roggisch deets at nospam.web.de
Sun Jul 27 08:20:09 EDT 2008


Randall Smith schrieb:
> I'd like to bundle Python with my app, which will be targeted at Linux, 
> Windows and Mac.  Discussions I've found about this tend to lead to 
> py2exe, freeze, etc, but I'd like to do something rather simple and am 
> seeking advice.
> 
> What I'd like to do is just copy the standard libraries and 
> executable(s) and adjust the paths in the environment variables.  The 
> libraries and executable(s) would reside in the same directory with the 
> application so that you could run the application without needing to 
> install it.  The directory might look like this:
> 
> $ ls
> 
> start-app.sh
> app_lib/
> python_lib/
> python_bin/
> 
> 
> start-app.sh would look like this:
> 
> #!/bin/sh
> 
> PATH="python_bin:$PATH" PYTHON_HOME="./python_lib" python app_lib/start.py
> 
> Of course, there would be a start-app.bat for Windows.
> 
> The PATH is altered to make sure the right python interpreter is found 
> and PYTHON_HOME makes sure the right (local) libraries are found.
> 
> Can this be done?

It might be doable (virtualenv shows it works, you might consider taking 
a look into it), but I would advise against it. py2exe and py2app for 
example do a great job to provide a way to distribute software in a way 
the respective target OS (and their users) are expecting it.

For example, OSX uses so-called "application bundles" which py2app 
(guess where the name comes from...) produces for you. Not using them 
might cripple you, because e.g. GUI-stuff isn't working properly (or 
will show an arbitrary icon in the dock, instead of one you chose).

Why do you insist on re-inventing a wheel that's rolling fine?

Diez



More information about the Python-list mailing list