bundling python with application

R

Randall Smith

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?

Randall
 
D

Diez B. Roggisch

Randall said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top