summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2016-09-25 10:54:27 +0200
committerSlávek Banko <[email protected]>2016-09-25 10:57:15 +0200
commitd6f454456232c37c2adc43da7172197dae4c973a (patch)
treebb33885b94cf648aeab06a8d236133229fc945b8
parent7973f920ef221c3168d1e46a96a1dd1ad7e0f5c5 (diff)
downloadpytqt-d6f454456232c37c2adc43da7172197dae4c973a.tar.gz
pytqt-d6f454456232c37c2adc43da7172197dae4c973a.zip
Improve python_tqt module initialization
This relates to bug 2693 Signed-off-by: Michele Calgaro <[email protected]> Signed-off-by: Slávek Banko <[email protected]> (cherry picked from commit 0b2f1c4760ceb98b6e3213999a1e4d48d24e91e8)
-rw-r--r--configure.py5
-rw-r--r--module-init.py35
2 files changed, 38 insertions, 2 deletions
diff --git a/configure.py b/configure.py
index ebedf9a..7077f3d 100644
--- a/configure.py
+++ b/configure.py
@@ -1458,14 +1458,15 @@ def main(argv):
# Create the additional Makefiles.
sipconfig.inform("Creating top level Makefile...")
- open('__init__.py', 'a').close()
-
sipconfig.ParentMakefile(
configuration=sipcfg,
subdirs=pyqt_modules + pyqt.tools(),
installs=(pyqt.module_installs(), pyqt.module_dir())
).generate()
+ # Install module initialization script.
+ create_config("__init__.py", os.path.join(src_dir, "module-init.py"), macros)
+
# Install the configuration module.
create_config("pyqtconfig.py", os.path.join(src_dir, "pyqtconfig.py.in"), macros)
diff --git a/module-init.py b/module-init.py
new file mode 100644
index 0000000..929a166
--- /dev/null
+++ b/module-init.py
@@ -0,0 +1,35 @@
+
+# Trinity-specific paths
+import sys, os
+tqt_modules = []
+for m_path in sys.path:
+ if os.path.exists(os.path.join(m_path, 'sip4_tqt')):
+ m_sip_dir = os.path.join(m_path, 'sip4_tqt')
+ tqt_modules.insert(0, m_sip_dir)
+ if os.path.exists(os.path.join(m_path, 'python_tqt')):
+ m_pyqt_dir = os.path.join(m_path, 'python_tqt')
+ tqt_modules.insert(0, m_pyqt_dir)
+for m_path in tqt_modules:
+ sys.path.insert(0, m_path)
+
+# Base modules
+__all__ = [
+ 'qt',
+ 'qtcanvas',
+ 'qtnetwork',
+ 'qtsql',
+ 'qttable',
+ 'qtui',
+ 'qtxml',
+]
+
+# Optional modules
+if os.path.exists(os.path.join(m_pyqt_dir, 'qtaxcontainer.so')):
+ __all__.append('qtaxcontainer')
+if os.path.exists(os.path.join(m_pyqt_dir, 'qtext.so')):
+ __all__.append('qtext')
+if os.path.exists(os.path.join(m_pyqt_dir, 'qtgl.so')):
+ __all__.append('qtgl')
+
+# Import namespaces
+from python_tqt import *