473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 7688
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PatchFactory Support | last post by:
Description: Professional and easy-to-use patch building environment that can help you to create instant patch packages for software and file updating. Generated patch packages are small size...
8
by: Olaf Meyer | last post by:
Sometimes if find it clumsy unsing the following approach building strings: cmd = "%s -start %s -end %s -dir %s" % (executable, startTime, endTime, directory) Especially if you have a lot of...
0
by: John Hunter | last post by:
I am trying to build python2.1 with alrge file support. I ran configure in a clean build tree and then edited the makefile # Compiler options OPT= -ggdb -O3 -Wall -Wstrict-prototypes...
7
by: Edward Diener | last post by:
I can install Python 2.4 on the Fedora 3 Linux system, but after I do a number of Linux utilities and commands, like yum, stop working because they were dependent on the Python 2.3 installation....
1
by: TPJ | last post by:
Hello, I have another, probably stupid, question. I'm working on some Python project, and I use some extensions written in C. I do all the development on my GNU/Linux box, so my setup.py script...
22
by: James Stroud | last post by:
Hello All, This is annoying. I am trying to build scipy right now but every .so file requires my adding "-lpython2.5 -lpthread -lm -lutil -ldl -shared" to the ld flags. Main Question: When...
17
by: Nirjhar Oberoi | last post by:
Hi, I am new to Linux and wanted to know how to use GCC to Compile the Code written in C? I dont want to use EMacs or VI for my editor. Can you suggest a good IDE for linux for C Programming.. ...
20
by: Ramdas | last post by:
How do I add users using Python scripts on a Linux machine? Someone has a script?
3
by: Micah Elliott | last post by:
Are there instructions somewhere on how to build Python (on linux) statically? This seems like a common thing to do want to do, but my searching isn't turning up much. If it is common, it would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.