2 # -*- coding: iso-8859-1 -*-
4 ################################################################################
6 # 2008 June 27th by Marcus 'EgS' Eggenberger <egs@quassel-irc.org> #
8 # The author disclaims copyright to this source code. #
9 # This Python Script is in the PUBLIC DOMAIN. #
11 ################################################################################
13 # ==============================
15 # ==============================
17 from subprocess import Popen, PIPE
19 # ==============================
21 # ==============================
22 def qtProperty(qtProperty):
24 Query persistent property of Qt via qmake
26 VALID_PROPERTIES = ['QT_INSTALL_PREFIX',
34 'QT_INSTALL_TRANSLATIONS',
35 'QT_INSTALL_CONFIGURATION',
36 'QT_INSTALL_EXAMPLES',
42 if qtProperty not in VALID_PROPERTIES:
45 qmakeProcess = Popen('qmake -query %s' % qtProperty, shell=True, stdout=PIPE, stderr=PIPE)
46 result = qmakeProcess.stdout.read().strip()
47 qmakeProcess.stdout.close()
51 def qtMakespec(qtMakespec):
53 Query a Makespec value of Qt via qmake
56 VALID_PROPERTIES = ['QMAKE_MACOSX_DEPLOYMENT_TARGET',
58 if qtMakespec not in VALID_PROPERTIES:
61 # QMAKE_MACOSX_DEPLOYMENT_TARGET sadly cannot be queried in the traditional way
63 # Inspired by https://code.qt.io/cgit/pyside/pyside-setup.git/tree/qtinfo.py?h=5.6
64 # Simplified, no caching, etc, as we're just looking for the macOS version.
65 # If a cleaner solution is desired, look into license compatibility in
66 # order to simply copy the above code.
68 current_dir = os.getcwd()
69 qmakeFakeProjectFile = os.path.join(current_dir, "qmake_empty_project.txt")
70 qmakeStashFile = os.path.join(current_dir, ".qmake.stash")
72 open(qmakeFakeProjectFile, 'a').close()
74 qmakeProcess = Popen('qmake -E %s' % qmakeFakeProjectFile, shell=True, stdout=PIPE, stderr=PIPE)
75 result = qmakeProcess.stdout.read().strip()
76 qmakeProcess.stdout.close()
79 # Clean up temporary files
81 os.remove(qmakeFakeProjectFile)
85 os.remove(qmakeStashFile)
89 # Result should be like this:
91 result_list = result.splitlines()
92 # Clear result so if nothing matches, nothing is returned
95 for line in result_list:
97 # Ignore lines without '='
100 # Find property = value
101 parts = line.split('=', 1)
102 prop = parts[0].strip()
103 value = parts[1].strip()
104 if (prop == qtMakespec):