Static linking of python and pyqt

M

Markus Dahlbokum

Hello,

I'm trying to link python statically with qt and pyqt. I've tried this in
several ways but never succeeded. At the moment the final make runs without
errors but I get import errors when accessing pyqt.
How can I solve this problem?

Markus

# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /opt/python-2.4.4/lib/python2.4/site.pyc
matches /opt/python-2.4.4/lib/python2.4/site.py
import site # precompiled from /opt/python-2.4.4/lib/python2.4/site.pyc
# /opt/python-2.4.4/lib/python2.4/os.pyc
matches /opt/python-2.4.4/lib/python2.4/os.py
import os # precompiled from /opt/python-2.4.4/lib/python2.4/os.pyc
import posix # builtin
# /opt/python-2.4.4/lib/python2.4/posixpath.pyc
matches /opt/python-2.4.4/lib/python2.4/posixpath.py
import posixpath # precompiled
from /opt/python-2.4.4/lib/python2.4/posixpath.pyc
# /opt/python-2.4.4/lib/python2.4/stat.pyc
matches /opt/python-2.4.4/lib/python2.4/stat.py
import stat # precompiled from /opt/python-2.4.4/lib/python2.4/stat.pyc
# /opt/python-2.4.4/lib/python2.4/UserDict.pyc
matches /opt/python-2.4.4/lib/python2.4/UserDict.py
import UserDict # precompiled
from /opt/python-2.4.4/lib/python2.4/UserDict.pyc
# /opt/python-2.4.4/lib/python2.4/copy_reg.pyc
matches /opt/python-2.4.4/lib/python2.4/copy_reg.py
import copy_reg # precompiled
from /opt/python-2.4.4/lib/python2.4/copy_reg.pyc
# /opt/python-2.4.4/lib/python2.4/types.pyc
matches /opt/python-2.4.4/lib/python2.4/types.py
import types # precompiled from /opt/python-2.4.4/lib/python2.4/types.pyc
# /opt/python-2.4.4/lib/python2.4/warnings.pyc
matches /opt/python-2.4.4/lib/python2.4/warnings.py
import warnings # precompiled
from /opt/python-2.4.4/lib/python2.4/warnings.pyc
# /opt/python-2.4.4/lib/python2.4/linecache.pyc
matches /opt/python-2.4.4/lib/python2.4/linecache.py
import linecache # precompiled
from /opt/python-2.4.4/lib/python2.4/linecache.pyc
import encodings # directory /opt/python-2.4.4/lib/python2.4/encodings
# /opt/python-2.4.4/lib/python2.4/encodings/__init__.pyc
matches /opt/python-2.4.4/lib/python2.4/encodings/__init__.py
import encodings # precompiled
from /opt/python-2.4.4/lib/python2.4/encodings/__init__.pyc
# /opt/python-2.4.4/lib/python2.4/codecs.pyc
matches /opt/python-2.4.4/lib/python2.4/codecs.py
import codecs # precompiled from /opt/python-2.4.4/lib/python2.4/codecs.pyc
import _codecs # builtin
# /opt/python-2.4.4/lib/python2.4/encodings/aliases.pyc
matches /opt/python-2.4.4/lib/python2.4/encodings/aliases.py
import encodings.aliases # precompiled
from /opt/python-2.4.4/lib/python2.4/encodings/aliases.pyc
# /opt/python-2.4.4/lib/python2.4/encodings/utf_8.pyc
matches /opt/python-2.4.4/lib/python2.4/encodings/utf_8.py
import encodings.utf_8 # precompiled
from /opt/python-2.4.4/lib/python2.4/encodings/utf_8.pyc
Python 2.4.4 (#1, Dec 7 2007, 11:16:51)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.import QtCore # builtin
import sip # builtin
Traceback (most recent call last):
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] site
# cleanup[1] encodings
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] PyQt4.QtCore
# cleanup[1] warnings
# cleanup[1] encodings.utf_8
# cleanup[1] codecs
# cleanup[1] types
# cleanup[1] signal
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[2] copy_reg
# cleanup[2] sip
# cleanup[2] posixpath
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 7 unfreed ints in 1 out of 3 blocks
# cleanup floats
 
M

Martin v. Löwis

I'm trying to link python statically with qt and pyqt. I've tried this in
several ways but never succeeded. At the moment the final make runs without
errors but I get import errors when accessing pyqt.
How can I solve this problem?

You'll need to include QtCore into Modules/config.c, preferably by
adding it to Modules/Setup.local.

HTH,
Martin
 
M

Martin v. Löwis

I'm trying to link python statically with qt and pyqt. I've tried this in
several ways but never succeeded. At the moment the final make runs without
errors but I get import errors when accessing pyqt.
How can I solve this problem?

You'll need to include QtCore into Modules/config.c, preferably by
adding it to Modules/Setup.local.

HTH,
Martin
 
M

Markus Dahlbokum

I'm trying to link python statically with qt and pyqt. I've tried this in
You'll need to include QtCore into Modules/config.c, preferably by
adding it to Modules/Setup.local.

HTH,
Martin

I tried this in combination with the QtCore libs from pyqt. But there seems to
be a conflict between the pyqt package and the linked libs. Therefore I tried
to link only qt statically and import pyqt dynamically. But in the
Setup.local you need to specify a module:

<module> <lib>

I just want the qt libs linked to the interpreter without accessing them by a
module. I tried the configure option '--with-libs='lib ...''. The make did
fine but the executable is too small and the qt symbols are not known by it.
How can I just link qt statically?

Thank you.

Markus
 
M

Martin v. Löwis

I just want the qt libs linked to the interpreter without accessing them by a
module. I tried the configure option '--with-libs='lib ...''. The make did
fine but the executable is too small and the qt symbols are not known by it.
How can I just link qt statically?

Why do you want to do this? If qt isn't actually *used* in Python (as
you don't include the pyqt modules), what effect do you expect from
such linking?

I think it linked just fine - it just didn't include any symbols,
because none were needed. That is the correct, expected behavior.
It all worked fine.

Regards,
Martin
 
M

Markus Dahlbokum

I just want the qt libs linked to the interpreter without accessing them
Why do you want to do this? If qt isn't actually *used* in Python (as
you don't include the pyqt modules), what effect do you expect from
such linking?

I think it linked just fine - it just didn't include any symbols,
because none were needed. That is the correct, expected behavior.
It all worked fine.

Regards,
Martin

I need an environment that can be delivered to our customers without
installing python, qt and pyqt. We want to provide the complete package.
In order to do so I need to link at least python and qt. How can this be done?

Of course a complete package with python, qt and pyqt would be the best
solution but there seem to be even more complications that way. If you can
help me with this I would be very grateful.

Thank you in advance.
Markus
 
D

Diez B. Roggisch

Markus said:
I need an environment that can be delivered to our customers without
installing python, qt and pyqt. We want to provide the complete package.
In order to do so I need to link at least python and qt. How can this be
done?

Of course a complete package with python, qt and pyqt would be the best
solution but there seem to be even more complications that way. If you can
help me with this I would be very grateful.

I don't think you will succeed in that attempt. Statically linking means
statically refering, as martin says. I'm not an expert, but as qt refers to
PyQt (via sip-bindings) but the latter one isn't explicitly refered to by
the python-interpreter itself, you won't get the linking right.

I've got the agfeo Tk-suite client running on my system - it's a windows +
linux qt-based app. And it ships completely with a version of qt, locally
installed into it's program-dir. An approach that is even more common in
OSX and Windows. So you might consider using that instead.

Diez
 
M

Martin v. Löwis

I need an environment that can be delivered to our customers without
installing python, qt and pyqt. We want to provide the complete package.
In order to do so I need to link at least python and qt. How can this be done?

You should link all extension modules into the Python executable,
through Setup.local
Of course a complete package with python, qt and pyqt would be the best
solution but there seem to be even more complications that way. If you can
help me with this I would be very grateful.

Not sure. You didn't explain what the precise problem is, so it's
difficult to help in correcting it.

Regards,
Martin
 
B

BlueBird

I need an environment that can be delivered to our customers without
installing python, qt and pyqt. We want to provide the complete package.
In order to do so I need to link at least python and qt. How can this be done?

Of course a complete package with python, qt and pyqt would be the best
solution but there seem to be even more complications that way. If you can
help me with this I would be very grateful.

If it's for windows, py2exe works like a charm for this kind of setup.

For windows + linux, you might one to try one of:
http://www.freehackers.org/Packaging_a_python_program
 

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

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top