Hello,

I was trying to compile PyQt while using Qt that is configured with a different namespace.

The steps to do that:

1. Configure sip with: configure.py DEFINES+=QT_NAMESPACE=x
2. Apply the attached patch (tested with PyQt 4.7.7 and Qt SDK 4.6.3)
3. Configure PyQt with: configure.py --qtnamespace=x -w

Maybe I reinvented the wheel and missed some options that would allow me to compile with a different namespace w/o having to resort to such a patch.

If this patch is correct or can be corrected and integrated in the upcoming snapshots it would be great.

Thanks,
Elias
Left base folder: C:\Temp\PyQt-win-gpl-4.7.7
Right base folder: C:\Temp\patchPyQt-win-gpl-4.7.7
--- designer\pluginloader.h     2010-09-20 14:14:04.000000000 +-0200
+++ designer\pluginloader.h     2010-10-18 17:26:23.000000000 +-0200
@@ -36,15 +36,15 @@
 #include <Python.h>
 
 #include <QDesignerCustomWidgetCollectionInterface>
 #include <QList>
 #include <QObject>
 
-
+QT_BEGIN_NAMESPACE
 class QDesignerCustomWidgetInterface;
-
+QT_END_NAMESPACE
 
 class PyCustomWidgets
     : public QObject, public QDesignerCustomWidgetCollectionInterface
 {
     Q_OBJECT
     Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
--- pylupdate\metatranslator.h  2010-09-20 14:14:04.000000000 +-0200
+++ pylupdate\metatranslator.h  2010-10-18 17:26:35.000000000 +-0200
@@ -39,13 +39,16 @@
 #include <qstring.h>
 #include <translator.h>
 #include <qlist.h>
 #include <qlocale.h>
 #include <qdir.h>
 
+
+QT_BEGIN_NAMESPACE
 class QTextCodec;
+QT_END_NAMESPACE
 
 class MetaTranslatorMessage : public TranslatorMessage
 {
 public:
     enum Type { Unfinished, Finished, Obsolete };
 
--- pylupdate\translator.h      2010-09-20 14:14:04.000000000 +-0200
+++ pylupdate\translator.h      2010-10-18 17:26:44.000000000 +-0200
@@ -39,13 +39,15 @@
 #include "QtCore/qbytearray.h"
 #include "QtCore/qstringlist.h"
 #include "QtCore/qlocale.h"
 #include <qtranslator.h>
 
 class TranslatorPrivate;
+QT_BEGIN_NAMESPACE
 template <typename T> class QList;
+QT_END_NAMESPACE
 
 class TranslatorMessage
 {
 public:
     TranslatorMessage();
     TranslatorMessage(const char * context, const char * sourceText,
--- qpy\QtCore\qpycore_api.h    2010-09-20 14:14:04.000000000 +-0200
+++ qpy\QtCore\qpycore_api.h    2010-10-18 12:43:23.000000000 +-0200
@@ -36,15 +36,15 @@
 #include <QCoreApplication>
 #include <QString>
 #include <QVariant>
 
 #include "qpycore_shared.h"
 
-
+QT_BEGIN_NAMESPACE
 class QObject;
-
+QT_END_NAMESPACE
 
 // Support for pyqtSlot() and pyqtSignature().
 PyObject *qpycore_pyqtslot(PyObject *args, PyObject *kwds);
 PyObject *qpycore_pyqtsignature(PyObject *args, PyObject *kwds);
 
 
--- qpy\QtCore\qpycore_pyqtboundsignal.h        2010-09-20 14:14:04.000000000 
+-0200
+++ qpy\QtCore\qpycore_pyqtboundsignal.h        2010-10-18 12:43:27.000000000 
+-0200
@@ -34,14 +34,15 @@
 
 #include <Python.h>
 
 #include "qpycore_chimera.h"
 
 
+QT_BEGIN_NAMESPACE
 class QObject;
-
+QT_END_NAMESPACE
 
 extern "C" {
 
 // This defines the structure of a bound PyQt signal.
 typedef struct {
     PyObject_HEAD
--- qpy\QtCore\qpycore_pyqtproxy.h      2010-09-20 14:14:04.000000000 +-0200
+++ qpy\QtCore\qpycore_pyqtproxy.h      2010-10-18 12:43:31.000000000 +-0200
@@ -43,13 +43,16 @@
 #include "qpycore_chimera.h"
 #include "qpycore_pyqtboundsignal.h"
 #include "qpycore_sip.h"
 #include "qpycore_types.h"
 
 
+QT_BEGIN_NAMESPACE
 class QMutex;
+QT_END_NAMESPACE
+
 class PyQt_PyObject;
 
 
 // This class is used as a signal on behalf of Python signals and as a slot on
 // behalf of Python callables.  It is derived from QObject but is not run
 // through moc.  Instead the normal moc-generated methods are handwritten in
--- qpy\QtCore\qpycore_qobject_helpers.h        2010-09-20 14:14:04.000000000 
+-0200
+++ qpy\QtCore\qpycore_qobject_helpers.h        2010-10-18 12:43:46.000000000 
+-0200
@@ -35,15 +35,15 @@
 #include <Python.h>
 
 #include <QMetaObject>
 
 #include "qpycore_sip.h"
 
-
+QT_BEGIN_NAMESPACE
 class QObject;
-
+QT_END_NAMESPACE
 
 const QMetaObject *qpycore_qobject_metaobject(sipSimpleWrapper *pySelf,
         sipTypeDef *base);
 int qpycore_qobject_qt_metacall(sipSimpleWrapper *pySelf, sipTypeDef *base,
         QMetaObject::Call _c, int _id, void **_a);
 int qpycore_qobject_qt_metacast(sipSimpleWrapper *pySelf, sipTypeDef *base,
--- qpy\QtCore\qpycore_sip.h    2010-09-20 14:14:04.000000000 +-0200
+++ qpy\QtCore\qpycore_sip.h    2010-10-18 16:48:28.000000000 +-0200
@@ -1,32 +1,32 @@
 // This provides access to the SIP generated code for the QtCore module.
 //
 // Copyright (c) 2010 Riverbank Computing Limited <i...@riverbankcomputing.com>
-// 
+//
 // This file is part of PyQt.
-// 
+//
 // This file may be used under the terms of the GNU General Public
 // License versions 2.0 or 3.0 as published by the Free Software
 // Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
 // included in the packaging of this file.  Alternatively you may (at
 // your option) use any later version of the GNU General Public
 // License if such license has been publicly approved by Riverbank
 // Computing Limited (or its successors, if any) and the KDE Free Qt
 // Foundation. In addition, as a special exception, Riverbank gives you
 // certain additional rights. These rights are described in the Riverbank
 // GPL Exception version 1.1, which can be found in the file
 // GPL_EXCEPTION.txt in this package.
-// 
+//
 // Please review the following information to ensure GNU General
 // Public Licensing requirements will be met:
 // http://trolltech.com/products/qt/licenses/licensing/opensource/. If
 // you are unsure which license is appropriate for your use, please
 // review the following information:
 // http://trolltech.com/products/qt/licenses/licensing/licensingoverview
 // or contact the sales department at sa...@riverbankcomputing.com.
-// 
+//
 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
 
 #ifndef _QPYCORE_SIP_H
 #define _QPYCORE_SIP_H
--- qpy\QtCore\qpycore_sip_helpers.h    2010-09-20 14:14:04.000000000 +-0200
+++ qpy\QtCore\qpycore_sip_helpers.h    2010-10-18 12:43:35.000000000 +-0200
@@ -34,16 +34,18 @@
 
 #include <Python.h>
 
 #include "qpycore_chimera.h"
 
 
+QT_BEGIN_NAMESPACE
 class QObject;
+QT_END_NAMESPACE
 
 
 // Forward declarations.
 QObject *qpycore_find_signal(QObject *qtx, const char **sig);
 bool qpycore_emit(QObject *qtx, int signal_index,
         const Chimera::Signature *parsed_signature, PyObject *sigargs);
 
 
 #endif
--- sip\QtCore\qglobal.sip      2010-09-20 14:14:02.000000000 +-0200
+++ sip\QtCore\qglobal.sip      2010-10-18 12:44:21.000000000 +-0200
@@ -355,20 +355,22 @@
 
 return 0;
 %End
 };
 // Hook's into Qt's resource system.
 %ModuleCode
+QT_BEGIN_NAMESPACE
 extern bool qRegisterResourceData(int, const unsigned char *, const unsigned 
char *, const unsigned char *);
 extern bool qUnregisterResourceData(int, const unsigned char *, const unsigned 
char *, const unsigned char *);
+QT_END_NAMESPACE
 %End
 
 bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, 
const unsigned char *);
 bool qUnregisterResourceData(int, const unsigned char *, const unsigned char 
*, const unsigned char *);
 bool qFuzzyCompare(double, double);
 bool qIsNull(double);
 %If (Qt_4_2_0 -)
 void qsrand(uint);
 %End
 %If (Qt_4_2_0 -)
 int qrand();
 %End
--- configure.py        2010-09-20 14:13:56.000000000 +-0200
+++ configure.py        2010-10-18 17:28:12.000000000 +-0200
@@ -30,13 +30,13 @@
 
 import sys
 import os
 import glob
 import optparse
 import shutil
-
+import re
 import sipconfig
 
 
 # Initialise the globals.
 pyqt_version = 0x040707
 pyqt_version_str = "4.7.7"
@@ -131,12 +131,14 @@
     p.add_option("-r", "--trace", action="store_true", default=False,
             dest="tracing", help="build modules with tracing enabled")
     p.add_option("-u", "--debug", action="store_true", default=False,
             help="build modules with debugging symbols")
     p.add_option("-w", "--verbose", action="count", default=0, dest="verbose",
             help="verbose output during configuration")
+    p.add_option("--qtnamespace", default="", dest="qtnamespace",
+            help="Wraps all Qt library code in 'namespace name")
 
     p.add_option("-c", "--concatenate", action="store_true", default=False,
             dest="concat", help="concatenate each module's C++ source files")
     p.add_option("-j", "--concatenate-split", type="int", default=1,
             metavar="N", dest="split",
             help="split the concatenated C++ source files into N pieces "
@@ -1820,12 +1822,14 @@
 # This is for certain broken Linux distros and is needed to make sure that
 # QT_SHARED is properly defined.
 CONFIG += link_prl
 TARGET = %s
 SOURCES = %s
 """ % (app, cpp_file))
+    if opts.qtnamespace:
+        f.write("QT_NAMESPACE = %s\n" % opts.qtnamespace)
 
     f.close()
 
     # Generate the source code.
     f = open(cpp_file, "w")
 
@@ -2073,12 +2077,23 @@
     macros = get_build_macros(args)
 
     if macros is None:
         p.print_help()
         sys.exit(2)
 
+    if opts.qtnamespace:
+        defines = macros.get('DEFINES', '')
+        ns_re = re.compile('(QT_NAMESPACE)\s*(=)\s*(\S+)')
+        ns_m  = ns_re.search(defines)
+        if not ns_m:
+            defines += ' QT_NAMESPACE=%s ' % opts.qtnamespace
+        elif ns_m.group(3) != opts.qtnamespace:
+            defines = ns_re.sub(r'\1\2%s' % opts.qtnamespace, defines)
+
+        macros['DEFINES'] = defines
+
     sipcfg.set_build_macros(macros)
 
     # Check Qt is what we need.
     pyqt = check_qt_installation(macros)
 
     # Check the licenses are compatible.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to