Debian Codegraph @

cmake/modules/FindPyQt5.py

raw symbols SCIP
1 # SPDX-FileCopyrightText: 2014 Simon Edwards <[email protected]>
2 # SPDX-FileCopyrightText: 2021 L. E. Segovia <[email protected]>
3 #
4 # SPDX-License-Identifier: BSD-3-Clause
5 #
6
7 import re
8 import sys
9 import os
10 import sysconfig
11
12 try:
13 # On Windows and Python 3.8+ python doesn't load module DLL's
14 # from the current PATH environment, therefore we should add
15 # path to Qt's DLL's manually. This variable is passed from
16 # FindPyQt5.cmake
17 for path in os.environ['PYTHONDLLPATH'].split(';'):
18 os.add_dll_directory(path)
19 except:
20 pass
21
22 import PyQt5.QtCore
23
24 print("pyqt_version:%06.0x" % PyQt5.QtCore.PYQT_VERSION)
25 print("pyqt_version_str:%s" % PyQt5.QtCore.PYQT_VERSION_STR)
26
27 pyqt_version_tag = ""
28 in_t = False
29 pyqt_config_list = PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"].split(' ')
30 for item in pyqt_config_list:
31 if item == "-t":
32 in_t = True
33 elif in_t:
34 if item.startswith("Qt_5"):
35 pyqt_version_tag = item
36 else:
37 in_t = False
38 print("pyqt_version_tag:%s" % pyqt_version_tag)
39
40 try:
41 index_n = pyqt_config_list.index('-n')
42 pyqt_sip_name = pyqt_config_list[index_n + 1]
43 print("pyqt_sip_name:%s" % pyqt_sip_name)
44 except ValueError:
45 pass
46
47 # If we use a system install with a custom PYTHONPATH, PyQt5
48 # may not be within the system tree.
49 pyqt5_dir = os.path.dirname(PyQt5.__file__)
50 lib_site_packages = sysconfig.get_path('platlib')
51 # Check this first.
52 if pyqt5_dir.startswith(lib_site_packages):
53 pyqt_sip_dir = os.path.join(sysconfig.get_path('platlib'), "PyQt5", "bindings")
54 else:
55 # If so, change it.
56 pyqt_sip_dir = os.path.join(pyqt5_dir, "bindings")
57
58 if not os.path.exists(pyqt_sip_dir): # Fallback for older PyQt5/SIP
59 pyqt_sip_dir = os.path.join(sys.prefix, "share", "sip", "PyQt5")
60 print("pyqt_sip_dir:%s" % pyqt_sip_dir)
61
62 print("pyqt_sip_flags:%s" % PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"])
63
64 tags = re.findall(r"-t ([^\s]+)", PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"])
65 print("pyqt_sip_tags:%s" % ",".join(tags))