aboutsummaryrefslogtreecommitdiffstats
path: root/qtinfo.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-04-23 14:38:39 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-04-30 09:31:17 +0000
commit6fe563b2aa15c2c23369acce353be69f6ea84c77 (patch)
treee0ef0c6f7ae4106424a9202745651d59e70bd558 /qtinfo.py
parent1d6bad63bcb6720078de1e78c1b495bf08d1c65b (diff)
Split and move various setup.py parts into different files
This is an initial effort to clean up setup.py. A new directory called build_scripts contains most of the logic for building, leaving setup.py as an entry point. The build_scripts directory contains the usual qtinfo, utils, and the setup.py content has been split into main.py and platform specific files under platforms subfolder. The testrunner script has been modified to find the new location of the utils module. Task-number: PYSIDE-558 Change-Id: I3e041d5116ca5c3f96c789317303b65a7b1bbd70 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'qtinfo.py')
-rw-r--r--qtinfo.py237
1 files changed, 0 insertions, 237 deletions
diff --git a/qtinfo.py b/qtinfo.py
deleted file mode 100644
index e3591d987..000000000
--- a/qtinfo.py
+++ /dev/null
@@ -1,237 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2017 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of PySide2.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-import os, sys, re, subprocess
-from distutils.spawn import find_executable
-
-class QtInfo(object):
- def __init__(self, qmake_command=None):
- self.initialized = False
-
- if qmake_command:
- self._qmake_command = qmake_command
- else:
- self._qmake_command = [find_executable("qmake"),]
-
- # Dict to cache qmake values.
- self._query_dict = {}
- # Dict to cache mkspecs variables.
- self._mkspecs_dict = {}
- # Initialize the properties.
- self._initProperties()
-
- def getQMakeCommand(self):
- qmake_command_string = self._qmake_command[0]
- for entry in self._qmake_command[1:]:
- qmake_command_string += " {}".format(entry)
- return qmake_command_string
-
- def getVersion(self):
- return self.getProperty("QT_VERSION")
-
- def getBinsPath(self):
- return self.getProperty("QT_INSTALL_BINS")
-
- def getLibsPath(self):
- return self.getProperty("QT_INSTALL_LIBS")
-
- def getLibsExecsPath(self):
- return self.getProperty("QT_INSTALL_LIBEXECS")
-
- def getPluginsPath(self):
- return self.getProperty("QT_INSTALL_PLUGINS")
-
- def getPrefixPath(self):
- return self.getProperty("QT_INSTALL_PREFIX")
-
- def getImportsPath(self):
- return self.getProperty("QT_INSTALL_IMPORTS")
-
- def getTranslationsPath(self):
- return self.getProperty("QT_INSTALL_TRANSLATIONS")
-
- def getHeadersPath(self):
- return self.getProperty("QT_INSTALL_HEADERS")
-
- def getDocsPath(self):
- return self.getProperty("QT_INSTALL_DOCS")
-
- def getQmlPath(self):
- return self.getProperty("QT_INSTALL_QML")
-
- def getMacOSMinDeploymentTarget(self):
- """ Return value is a macOS version or None. """
- return self.getProperty("QMAKE_MACOSX_DEPLOYMENT_TARGET")
-
- def getBuildType(self):
- """
- Return value is either debug, release, debug_release, or None.
- """
- return self.getProperty("BUILD_TYPE")
-
- def getSrcDir(self):
- """ Return path to Qt src dir or None.. """
- return self.getProperty("QT_INSTALL_PREFIX/src")
-
- def getProperty(self, prop_name):
- if prop_name not in self._query_dict:
- return None
- return self._query_dict[prop_name]
-
- def getProperties(self):
- return self._query_dict
-
- def getMkspecsVariables(self):
- return self._mkspecs_dict
-
- def _getQMakeOutput(self, args_list = []):
- cmd = self._qmake_command + args_list
- proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, shell=False)
- output = proc.communicate()[0]
- proc.wait()
- if proc.returncode != 0:
- return None
- if sys.version_info >= (3,):
- output = str(output, 'ascii').strip()
- else:
- output = output.strip()
- return output
-
- def _parseQueryProperties(self, process_output):
- props = {}
- if not process_output:
- return props
- lines = [s.strip() for s in process_output.splitlines()]
- for line in lines:
- if line and ':' in line:
- key, value = line.split(':', 1)
- props[key] = value
- return props
-
- def _getQueryProperties(self):
- output = self._getQMakeOutput(['-query'])
- self._query_dict = self._parseQueryProperties(output)
-
- def _parseQtBuildType(self):
- key = 'QT_CONFIG'
- if key not in self._mkspecs_dict:
- return None
-
- qt_config = self._mkspecs_dict[key]
- if 'debug_and_release' in qt_config:
- return 'debug_and_release'
-
- split = qt_config.split(' ')
- if 'release' in split and 'debug' in split:
- return 'debug_and_release'
-
- if 'release' in split:
- return 'release'
-
- if 'debug' in split:
- return 'debug'
-
- return None
-
- def _getOtherProperties(self):
- # Get the src property separately, because it is not returned by
- # qmake unless explicitly specified.
- key = 'QT_INSTALL_PREFIX/src'
- result = self._getQMakeOutput(['-query', key])
- self._query_dict[key] = result
-
- # Get mkspecs variables and cache them.
- self._getQMakeMkspecsVariables()
-
- # Get macOS minimum deployment target.
- key = 'QMAKE_MACOSX_DEPLOYMENT_TARGET'
- if key in self._mkspecs_dict:
- self._query_dict[key] = self._mkspecs_dict[key]
-
- # Figure out how Qt was built:
- # debug mode, release mode, or both.
- build_type = self._parseQtBuildType()
- if build_type:
- self._query_dict['BUILD_TYPE'] = build_type
-
- def _initProperties(self):
- self._getQueryProperties()
- self._getOtherProperties()
-
- def _getQMakeMkspecsVariables(self):
- # Create empty temporary qmake project file.
- temp_file_name = 'qmake_fake_empty_project.txt'
- open(temp_file_name, 'a').close()
-
- # Query qmake for all of its mkspecs variables.
- qmakeOutput = self._getQMakeOutput(['-E', temp_file_name])
- lines = [s.strip() for s in qmakeOutput.splitlines()]
- pattern = re.compile(r"^(.+?)=(.+?)$")
- for line in lines:
- found = pattern.search(line)
- if found:
- key = found.group(1).strip()
- value = found.group(2).strip()
- self._mkspecs_dict[key] = value
-
- # We need to clean up after qmake, which always creates a
- # .qmake.stash file after a -E invocation.
- qmake_stash_file = os.path.join(os.getcwd(), ".qmake.stash")
- if os.path.exists(qmake_stash_file):
- os.remove(qmake_stash_file)
-
- # Also clean up the temporary empty project file.
- if os.path.exists(temp_file_name):
- os.remove(temp_file_name)
-
- version = property(getVersion)
- bins_dir = property(getBinsPath)
- libs_dir = property(getLibsPath)
- lib_execs_dir = property(getLibsExecsPath)
- plugins_dir = property(getPluginsPath)
- prefix_dir = property(getPrefixPath)
- qmake_command = property(getQMakeCommand)
- imports_dir = property(getImportsPath)
- translations_dir = property(getTranslationsPath)
- headers_dir = property(getHeadersPath)
- docs_dir = property(getDocsPath)
- qml_dir = property(getQmlPath)
- macos_min_deployment_target = property(getMacOSMinDeploymentTarget)
- build_type = property(getBuildType)
- src_dir = property(getSrcDir)