Kaynağa Gözat

Improve python_tqt module initialization

This relates to bug 2693

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Slávek Banko 2 yıl önce
ebeveyn
işleme
0b2f1c4760
2 değiştirilmiş dosya ile 38 ekleme ve 2 silme
  1. 3
    2
      configure.py
  2. 35
    0
      module-init.py

+ 3
- 2
configure.py Dosyayı Görüntüle

@@ -1458,14 +1458,15 @@ def main(argv):
1458 1458
     # Create the additional Makefiles.
1459 1459
     sipconfig.inform("Creating top level Makefile...")
1460 1460
 
1461
-    open('__init__.py', 'a').close()
1462
-
1463 1461
     sipconfig.ParentMakefile(
1464 1462
         configuration=sipcfg,
1465 1463
         subdirs=pyqt_modules + pyqt.tools(),
1466 1464
         installs=(pyqt.module_installs(), pyqt.module_dir())
1467 1465
     ).generate()
1468 1466
 
1467
+    # Install module initialization script.
1468
+    create_config("__init__.py", os.path.join(src_dir, "module-init.py"), macros)
1469
+
1469 1470
     # Install the configuration module.
1470 1471
     create_config("pyqtconfig.py", os.path.join(src_dir, "pyqtconfig.py.in"), macros)
1471 1472
 

+ 35
- 0
module-init.py Dosyayı Görüntüle

@@ -0,0 +1,35 @@
1
+
2
+# Trinity-specific paths
3
+import sys, os
4
+tqt_modules = []
5
+for m_path in sys.path:
6
+    if os.path.exists(os.path.join(m_path, 'sip4_tqt')):
7
+        m_sip_dir = os.path.join(m_path, 'sip4_tqt')
8
+        tqt_modules.insert(0, m_sip_dir)
9
+    if os.path.exists(os.path.join(m_path, 'python_tqt')):
10
+        m_pyqt_dir = os.path.join(m_path, 'python_tqt')
11
+        tqt_modules.insert(0, m_pyqt_dir)
12
+for m_path in tqt_modules:
13
+    sys.path.insert(0, m_path)
14
+
15
+# Base modules
16
+__all__ = [
17
+ 'qt',
18
+ 'qtcanvas',
19
+ 'qtnetwork',
20
+ 'qtsql',
21
+ 'qttable',
22
+ 'qtui',
23
+ 'qtxml',
24
+]
25
+
26
+# Optional modules
27
+if os.path.exists(os.path.join(m_pyqt_dir, 'qtaxcontainer.so')):
28
+    __all__.append('qtaxcontainer')
29
+if os.path.exists(os.path.join(m_pyqt_dir, 'qtext.so')):
30
+    __all__.append('qtext')
31
+if os.path.exists(os.path.join(m_pyqt_dir, 'qtgl.so')):
32
+    __all__.append('qtgl')
33
+
34
+# Import namespaces
35
+from python_tqt import *

Loading…
İptal
Kaydet