469,299 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

building a linux executable

Hello,

I'm trying to package my python program into a linux executable using
cx_freeze. The goal is that the user should require python on their
system.

I've managed to make the binaries on Fedora Core 6 and they run fine.
However, when I move to Ubuntu (tested on Ubuntu Server 7.04 and
xUbuntu Desktop 7.04), the program fails to run with the following
error:

ImportError: no module named _md5

_md5 being imported by the hashlib module because the import of
_hashlib.so failed.

When I try to import the _hashlib module manually, I see that it
cannot find libssl.so.6 (The _hashlib module in the standard python
installation which came with Ubuntu works just fine). If I manually
copy the libssl.so.6 file from FC6 (its really a symlink pointing to
libssl.so.0.9.8b) to Ubuntu and make the symlink in /lib, it works
fine (the next error is related to libcrypto, libxslt and libjpeg (i'm
also using libxml, libxsl and PIL in my application).

I've scoured the net and it seems that _hashlib.so is dynamically
linked to libssl which is not being "integrated" into the build by
cx_Freeze. Similarly, there are other files with the same problem.

Does anyone have any idea how to make cx_Freeze make a linux
executable which is portable across *nix distros?

Thanks in advance,
-Prateek Sureka

Oct 24 '07 #1
8 7441
Prateek wrote:
I'm trying to package my python program into a linux executable
using cx_freeze. The goal is that the user should require python
on their system.

I've managed to make the binaries on Fedora Core 6 and they run
fine. However, when I move to Ubuntu (tested on Ubuntu Server 7.04
and xUbuntu Desktop 7.04), the program fails to run with the
following error:
I'm sorry I cannot help, but how many linux distros have no python
installed or no packages of it?

Regards,
Björn

--
BOFH excuse #151:

Some one needed the powerstrip, so they pulled the switch plug.

Oct 24 '07 #2
On 24 Okt, 14:20, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n...@spamgourmet.comwrote:
>
I'm sorry I cannot help, but how many linux distros have no python
installed or no packages of it?
It's not usually the absence of Python that's the problem. What if
your application uses various extension modules which in turn rely on
various libraries (of the .so or .a kind)? It may be more convenient
to bundle all these libraries instead of working out the package
dependencies for all the target distributions, even if you know them
all.

Paul

Oct 24 '07 #3
Paul Boddie wrote:
It's not usually the absence of Python that's the problem. What if
your application uses various extension modules which in turn rely
on various libraries (of the .so or .a kind)? It may be more
convenient to bundle all these libraries instead of working out
the package dependencies for all the target distributions, even if
you know them all.
True, thanks for clarification.

Regards,
Björn

--
BOFH excuse #218:

The UPS doesn't have a battery backup.

Oct 24 '07 #4
On 24 Okt, 16:10, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n...@spamgourmet.comwrote:
Paul Boddie wrote:
It's not usually the absence of Python that's the problem. What if
your application uses various extension modules which in turn rely
on various libraries (of the .so or .a kind)? It may be more
convenient to bundle all these libraries instead of working out
the package dependencies for all the target distributions, even if
you know them all.

True, thanks for clarification.
Any suggestions, then? ;-)

I've also run into similar issues with cx_Freeze: I wanted to package
a game written using PyGame, which itself requires some SDL libraries,
which in turn require different libraries like smpeg (if I remember
correctly). It gets to the point where one is effectively building a
Python distribution (another question asked recently but not answered
sufficiently), which has minimal linkage to other libraries - perhaps
the system C libraries, some X11 libraries, and nothing more. Some
ideas about doing that successfully (perhaps LSB enters the picture)
would be quite useful.

Paul

Oct 24 '07 #5
On Oct 24, 5:25 pm, Paul Boddie <p...@boddie.org.ukwrote:
On 24 Okt, 14:20, Bjoern Schliessmann <usenet-

mail-0306.20.chr0n...@spamgourmet.comwrote:
I'm sorry I cannot help, but how many linux distros have no python
installed or no packages of it?

It's not usually the absence of Python that's the problem. What if
your application uses various extension modules which in turn rely on
various libraries (of the .so or .a kind)? It may be more convenient
to bundle all these libraries instead of working out the package
dependencies for all the target distributions, even if you know them
all.

Paul
Thanks Paul,

So I've bundled all the extension modules (cx_Freeze helped me out
with that). Here is what I did:

if sys.platform.startswith("linux"):
import [add a bunch of imports here]

This import statement immediately imports all modules which will be
required. Hence, cx_Freeze is easily able to find them and I can put
all the .so files with the distro.

The problem is that some of these .so files (_hashlib.so) are hard-
linked to /lib/libssl.so and /lib/libcrypto.so. I cannot simply just
copy those (libssl/libcrypto) files into the distribution folder (and
cx_Freeze won't do anything about them because they are not Python
modules). I need a way to figure out how to get _hashlib.so to refer
to a libssl.so which is in the same directory (I would have thunk that
it should use the PATH environment variable - apparently not).

This seems to be a simple enough problem, doesn't it??

NB: Has the community come up with a better way to distribute Python
executables on linux? I'd also like to hear from folks who've got
linux distributables of medium to large scale python programs...

Oct 24 '07 #6
On Oct 24, 5:08 pm, Prateek <sure...@gmail.comwrote:
On Oct 24, 5:25 pm, Paul Boddie <p...@boddie.org.ukwrote:
On 24 Okt, 14:20, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n...@spamgourmet.comwrote:
I'm sorry I cannot help, but how many linux distros have no python
installed or no packages of it?
It's not usually the absence of Python that's the problem. What if
your application uses various extension modules which in turn rely on
various libraries (of the .so or .a kind)? It may be more convenient
to bundle all these libraries instead of working out the package
dependencies for all the target distributions, even if you know them
all.
Paul

Thanks Paul,

So I've bundled all the extension modules (cx_Freeze helped me out
with that). Here is what I did:

if sys.platform.startswith("linux"):
import [add a bunch of imports here]

This import statement immediately imports all modules which will be
required. Hence, cx_Freeze is easily able to find them and I can put
all the .so files with the distro.

The problem is that some of these .so files (_hashlib.so) are hard-
linked to /lib/libssl.so and /lib/libcrypto.so. I cannot simply just
copy those (libssl/libcrypto) files into the distribution folder (and
cx_Freeze won't do anything about them because they are not Python
modules). I need a way to figure out how to get _hashlib.so to refer
to a libssl.so which is in the same directory (I would have thunk that
it should use the PATH environment variable - apparently not).

The environment variable you want is LD_LIBRARY_PATH.

Also, if you're not aware, the ldd command can print out the library
dependencies.

This seems to be a simple enough problem, doesn't it??

NB: Has the community come up with a better way to distribute Python
executables on linux? I'd also like to hear from folks who've got
linux distributables of medium to large scale python programs...
Since most Linux systems have Python installed these days, the impetus
isn't quite as strong, even given the issues brought up here.
Carl Banks

Oct 25 '07 #7
Paul Boddie wrote:
Any suggestions, then? ;-)
Not really; I've got a vaguely similar problem myself -- several
Debian systems with Python 2.4 and Python 2.5. But modules I need
(wxWidgets 2.8 and Twisted) aren't available as Python 2.5 packages
for Debian, so I'm stuck with 2.4. Packages from unstable won't
work because Twisted has a binary part that is linked against
another libc. I don't really want to compile and install manually
from tarballs everywhere, and building .deb packages with Python is
complicated.

Regards,
Björn

--
BOFH excuse #151:

Some one needed the powerstrip, so they pulled the switch plug.

Oct 25 '07 #8

Hi,

Some time ago, I compiled a small list of tools to perform the some
"python executable bundling" tasks.

It might be useful for you. Here is the list:

http://www.freehackers.org/Packaging_a_python_program
Philippe

Oct 29 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Olaf Meyer | last post: by
reply views Thread by John Hunter | last post: by
7 posts views Thread by Edward Diener | last post: by
22 posts views Thread by James Stroud | last post: by
17 posts views Thread by Nirjhar Oberoi | last post: by
3 posts views Thread by Micah Elliott | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.