diff options
Diffstat (limited to 'examples/utils/pyside_config.py')
-rw-r--r-- | examples/utils/pyside_config.py | 63 |
1 files changed, 14 insertions, 49 deletions
diff --git a/examples/utils/pyside_config.py b/examples/utils/pyside_config.py index 02d4a5da2..d3067eec1 100644 --- a/examples/utils/pyside_config.py +++ b/examples/utils/pyside_config.py @@ -1,44 +1,7 @@ -############################################################################# -## -## Copyright (C) 2019 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Qt for Python examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -from distutils import sysconfig +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import sysconfig from enum import Enum import glob import os @@ -115,10 +78,12 @@ options.append(("--shiboken-module-shared-libraries-cmake", options.append(("--pyside-shared-libraries-qmake", lambda: get_shared_libraries_qmake(Package.PYSIDE_MODULE), pyside_libs_error, - "Print paths of f{PYSIDE_MODULE} shared libraries (.so's, .dylib's, .dll's) for qmake")) + "Print paths of f{PYSIDE_MODULE} shared libraries (.so's, .dylib's, .dll's) " + "for qmake")) options.append(("--pyside-shared-libraries-cmake", lambda: get_shared_libraries_cmake(Package.PYSIDE_MODULE), pyside_libs_error, - f"Print paths of {PYSIDE_MODULE} shared libraries (.so's, .dylib's, .dll's) for cmake")) + f"Print paths of {PYSIDE_MODULE} shared libraries (.so's, .dylib's, .dll's) " + "for cmake")) options_usage = '' for i, (flag, _, _, description) in enumerate(options): @@ -190,11 +155,11 @@ def link_option(lib): # libraries when compiling the project baseName = os.path.basename(lib) link = ' -l' - if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '/absolute/path/libfoo.so' + if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '/absolute/path/libfoo.so' link = lib - elif sys.platform in ['darwin']: # Darwin: 'libfoo.so' -> '-lfoo' + elif sys.platform in ['darwin']: # Darwin: 'libfoo.so' -> '-lfoo' link += os.path.splitext(baseName[3:])[0] - else: # Windows: 'libfoo.dll' -> 'libfoo.dll' + else: # Windows: 'libfoo.dll' -> 'libfoo.dll' link += os.path.splitext(baseName)[0] return link @@ -231,13 +196,13 @@ def find_package_path(dir_name): return None -# Return version as "3.6" +# Return version as "x.y" (e.g. 3.9, 3.12, etc) def python_version(): return str(sys.version_info[0]) + '.' + str(sys.version_info[1]) def get_python_include_path(): - return sysconfig.get_python_inc() + return sysconfig.get_path('include') def python_link_flags_qmake(): @@ -249,7 +214,7 @@ def python_link_flags_qmake(): # e.g.: "Program Files" to "Progra~1" for d in libdir.split("\\"): if " " in d: - libdir = libdir.replace(d, d.split(" ")[0][:-1]+"~1") + libdir = libdir.replace(d, d.split(" ")[0][:-1] + "~1") lib_flags = flags['lib'] return f'-L{libdir} -l{lib_flags}' elif sys.platform == 'darwin': |