File indexing completed on 2024-05-12 04:22:35
0001 # SPDX-FileCopyrightText: 2014 Simon Edwards <simon@simonzone.com> 0002 # SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me> 0003 # 0004 # SPDX-License-Identifier: BSD-3-Clause 0005 # 0006 0007 import re 0008 import sys 0009 import os 0010 import sysconfig 0011 0012 try: 0013 # On Windows and Python 3.8+ python doesn't load module DLL's 0014 # from the current PATH environment, therefore we should add 0015 # path to Qt's DLL's manually. This variable is passed from 0016 # FindPyQt5.cmake 0017 for path in os.environ['PYTHONDLLPATH'].split(';'): 0018 os.add_dll_directory(path) 0019 except: 0020 pass 0021 0022 import PyQt5.QtCore 0023 0024 print("pyqt_version:%06.0x" % PyQt5.QtCore.PYQT_VERSION) 0025 print("pyqt_version_str:%s" % PyQt5.QtCore.PYQT_VERSION_STR) 0026 0027 pyqt_version_tag = "" 0028 in_t = False 0029 pyqt_config_list = PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"].split(' ') 0030 for item in pyqt_config_list: 0031 if item == "-t": 0032 in_t = True 0033 elif in_t: 0034 if item.startswith("Qt_5"): 0035 pyqt_version_tag = item 0036 else: 0037 in_t = False 0038 print("pyqt_version_tag:%s" % pyqt_version_tag) 0039 0040 try: 0041 index_n = pyqt_config_list.index('-n') 0042 pyqt_sip_name = pyqt_config_list[index_n + 1] 0043 print("pyqt_sip_name:%s" % pyqt_sip_name) 0044 except ValueError: 0045 pass 0046 0047 # If we use a system install with a custom PYTHONPATH, PyQt5 0048 # may not be within the system tree. 0049 pyqt5_dir = os.path.dirname(PyQt5.__file__) 0050 lib_site_packages = sysconfig.get_path('platlib') 0051 # Check this first. 0052 if pyqt5_dir.startswith(lib_site_packages): 0053 pyqt_sip_dir = os.path.join(sysconfig.get_path('platlib'), "PyQt5", "bindings") 0054 else: 0055 # If so, change it. 0056 pyqt_sip_dir = os.path.join(pyqt5_dir, "bindings") 0057 0058 if not os.path.exists(pyqt_sip_dir): # Fallback for older PyQt5/SIP 0059 pyqt_sip_dir = os.path.join(sys.prefix, "share", "sip", "PyQt5") 0060 print("pyqt_sip_dir:%s" % pyqt_sip_dir) 0061 0062 print("pyqt_sip_flags:%s" % PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"]) 0063 0064 tags = re.findall(r"-t ([^\s]+)", PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"]) 0065 print("pyqt_sip_tags:%s" % ",".join(tags))