summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-05-15 15:16:21 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-05-23 10:39:55 +0000
commit71249b93a5d12a320b44c608c05fb9d220788a18 (patch)
treeebe8764115184dcbb6e271d146a1e63998d3f1cd
parent9722bf66fb962d4c7a4be172c36efd23ebae32e7 (diff)
Format python files to use PEP8
Change-Id: I8dc16c10565da8f93ba5cb7cace004f8eaf52236 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--build_scripts/main.py126
-rw-r--r--build_scripts/qtinfo.py128
-rw-r--r--build_scripts/utils.py116
-rw-r--r--testing/runner.py18
4 files changed, 194 insertions, 194 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index b22249ab..26fc191c 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -74,7 +74,7 @@ def get_package_version():
return final_version
# Buildable extensions.
-containedModules = ['shiboken2', 'pyside2', 'pyside2-tools']
+contained_modules = ['shiboken2', 'pyside2', 'pyside2-tools']
# Git submodules: ["submodule_name",
# "location_relative_to_sources_folder"]
@@ -122,7 +122,7 @@ except ImportError:
pass
from .qtinfo import QtInfo
-from .utils import rmtree, detectClang, copyfile, copydir, run_process_output, run_process
+from .utils import rmtree, detect_clang, copyfile, copydir, run_process_output, run_process
from .utils import update_env_path, init_msvc_env, filter_match, macos_fix_rpaths_for_library
from .platforms.unix import prepare_packages_posix
from .platforms.windows_desktop import prepare_packages_win32
@@ -148,7 +148,7 @@ def check_allowed_python_version():
check_allowed_python_version()
-qtSrcDir = ''
+qt_src_dir = ''
# This is used automatically by distutils.command.install object, to
# specify final installation location.
@@ -225,9 +225,9 @@ def is_debug_python():
# Return a prefix suitable for the _install/_build directory
def prefix():
- virtualEnvName = os.environ.get('VIRTUAL_ENV', None)
- if virtualEnvName is not None:
- name = os.path.basename(virtualEnvName)
+ virtual_env_name = os.environ.get('VIRTUAL_ENV', None)
+ if virtual_env_name is not None:
+ name = os.path.basename(virtual_env_name)
else:
name = "pyside"
name += str(sys.version_info[0])
@@ -238,14 +238,14 @@ def prefix():
return name
# Initialize, pull and checkout submodules
-def prepareSubModules():
+def prepare_sub_modules():
print("Initializing submodules for PySide2 version: {}".format(
get_package_version()))
submodules_dir = os.path.join(setup_script_dir, "sources")
# Create list of [name, desired branch, absolute path, desired
# branch] and determine whether all submodules are present
- needInitSubModules = False
+ need_init_sub_modules = False
for m in submodules:
module_name = m[0]
@@ -253,10 +253,10 @@ def prepareSubModules():
module_dir = os.path.join(submodules_dir, module_dir, module_name)
# Check for non-empty directory (repository checked out)
if not os.listdir(module_dir):
- needInitSubModules = True
+ need_init_sub_modules = True
break
- if needInitSubModules:
+ if need_init_sub_modules:
git_update_cmd = ["git", "submodule", "update", "--init"]
if run_process(git_update_cmd) != 0:
m = ("Failed to initialize the git submodules: "
@@ -294,10 +294,10 @@ def get_qt_version():
return qt_version
-def prepareBuild():
+def prepare_build():
if (os.path.isdir(".git") and not OPTION_IGNOREGIT and
not OPTION_ONLYPACKAGE and not OPTION_REUSE_BUILD):
- prepareSubModules()
+ prepare_sub_modules()
# Clean up temp and package folders
for n in [pyside_package_dir_name, "build"]:
d = os.path.join(setup_script_dir, n)
@@ -317,17 +317,17 @@ def prepareBuild():
os.makedirs(pkg_dir)
# locate Qt sources for the documentation
if OPTION_QT_SRC is None:
- installPrefix = qtinfo.prefix_dir
- if installPrefix:
- global qtSrcDir
+ install_prefix = qtinfo.prefix_dir
+ if install_prefix:
+ global qt_src_dir
# In-source, developer build
- if installPrefix.endswith("qtbase"):
- qtSrcDir = installPrefix
+ if install_prefix.endswith("qtbase"):
+ qt_src_dir = install_prefix
else: # SDK: Use 'Src' directory
- qtSrcDir = os.path.join(os.path.dirname(installPrefix),
+ qt_src_dir = os.path.join(os.path.dirname(install_prefix),
'Src', 'qtbase')
-class pyside_install(_install):
+class PysideInstall(_install):
def __init__(self, *args, **kwargs):
_install.__init__(self, *args, **kwargs)
@@ -352,7 +352,7 @@ class pyside_install(_install):
_install.run(self)
log.info('*** Install completed')
-class pyside_develop(_develop):
+class PysideDevelop(_develop):
def __init__(self, *args, **kwargs):
_develop.__init__(self, *args, **kwargs)
@@ -361,7 +361,7 @@ class pyside_develop(_develop):
self.run_command("build")
_develop.run(self)
-class pyside_bdist_egg(_bdist_egg):
+class PysideBdistEgg(_bdist_egg):
def __init__(self, *args, **kwargs):
_bdist_egg.__init__(self, *args, **kwargs)
@@ -370,7 +370,7 @@ class pyside_bdist_egg(_bdist_egg):
self.run_command("build")
_bdist_egg.run(self)
-class pyside_build_ext(_build_ext):
+class PysideBuildExt(_build_ext):
def __init__(self, *args, **kwargs):
_build_ext.__init__(self, *args, **kwargs)
@@ -379,7 +379,7 @@ class pyside_build_ext(_build_ext):
pass
if wheel_module_exists:
- class pyside_build_wheel(_bdist_wheel):
+ class PysideBuildWheel(_bdist_wheel):
def __init__(self, *args, **kwargs):
_bdist_wheel.__init__(self, *args, **kwargs)
@@ -405,13 +405,13 @@ if wheel_module_exists:
# Override the platform name to contain the correct
# minimum deployment target.
# This is used in the final wheel name.
- self.plat_name = pyside_build.macos_plat_name()
+ self.plat_name = PysideBuild.macos_plat_name()
_bdist_wheel.finalize_options(self)
# pyside_build_py and pyside_install_lib are reimplemented to preserve
# symlinks when distutils / setuptools copy files to various
# directories through the different build stages.
-class pyside_build_py(_build_py):
+class PysideBuildPy(_build_py):
def __init__(self, *args, **kwargs):
_build_py.__init__(self, *args, **kwargs)
@@ -427,7 +427,7 @@ class pyside_build_py(_build_py):
# Using our own copyfile makes sure to preserve symlinks.
copyfile(srcfile, target)
-class pyside_install_lib(_install_lib):
+class PysideInstallLib(_install_lib):
def __init__(self, *args, **kwargs):
_install_lib.__init__(self, *args, **kwargs)
@@ -448,7 +448,7 @@ class pyside_install_lib(_install_lib):
return
return outfiles
-class pyside_build(_build):
+class PysideBuild(_build):
def __init__(self, *args, **kwargs):
_build.__init__(self, *args, **kwargs)
@@ -456,7 +456,7 @@ class pyside_build(_build):
def finalize_options(self):
os_name_backup = os.name
if sys.platform == 'darwin':
- self.plat_name = pyside_build.macos_plat_name()
+ self.plat_name = PysideBuild.macos_plat_name()
# This is a hack to circumvent the dubious check in
# distutils.commands.build -> finalize_options, which only
# allows setting the plat_name for windows NT.
@@ -489,7 +489,7 @@ class pyside_build(_build):
self.build_tests = False
def run(self):
- prepareBuild()
+ prepare_build()
platform_arch = platform.architecture()[0]
log.info("Python architecture is {}".format(platform_arch))
@@ -567,17 +567,17 @@ class pyside_build(_build):
else:
py_include_dir = os.path.join(py_prefix,
"include/python{}".format(py_version))
- dbgPostfix = ""
+ dbg_postfix = ""
if build_type == "Debug":
- dbgPostfix = "_d"
+ dbg_postfix = "_d"
if sys.platform == "win32":
if OPTION_MAKESPEC == "mingw":
static_lib_name = "libpython{}{}.a".format(
- py_version.replace(".", ""), dbgPostfix)
+ py_version.replace(".", ""), dbg_postfix)
py_library = os.path.join(py_libdir, static_lib_name)
else:
python_lib_name = "python{}{}.lib".format(
- py_version.replace(".", ""), dbgPostfix)
+ py_version.replace(".", ""), dbg_postfix)
py_library = os.path.join(py_libdir, python_lib_name)
else:
lib_exts = ['.so']
@@ -593,13 +593,13 @@ class pyside_build(_build):
# static library as last gasp
lib_exts.append('.a')
- if sys.version_info[0] == 2 and dbgPostfix:
+ if sys.version_info[0] == 2 and dbg_postfix:
# For Python2 add a duplicate set of extensions
- # combined with the dbgPostfix, so we test for both the
+ # combined with the dbg_postfix, so we test for both the
# debug version of the lib and the normal one.
# This allows a debug PySide2 to be built with a
# non-debug Python.
- lib_exts = [dbgPostfix + e for e in lib_exts] + lib_exts
+ lib_exts = [dbg_postfix + e for e in lib_exts] + lib_exts
python_library_found = False
libs_tried = []
@@ -669,24 +669,24 @@ class pyside_build(_build):
qt_version = get_qt_version()
# Update the PATH environment variable
- additionalPaths = [py_scripts_dir, qt_dir]
+ additional_paths = [py_scripts_dir, qt_dir]
# Add Clang to path for Windows.
# Revisit once Clang is bundled with Qt.
if (sys.platform == "win32" and
LooseVersion(self.qtinfo.version) >= LooseVersion("5.7.0")):
- clangDir = detectClang()
- if clangDir[0]:
- clangBinDir = os.path.join(clangDir[0], 'bin')
+ clang_dir = detect_clang()
+ if clang_dir[0]:
+ clangBinDir = os.path.join(clang_dir[0], 'bin')
if not clangBinDir in os.environ.get('PATH'):
log.info("Adding {} as detected by {} to PATH".format(
- clangBinDir, clangDir[1]))
- additionalPaths.append(clangBinDir)
+ clangBinDir, clang_dir[1]))
+ additional_paths.append(clangBinDir)
else:
raise DistutilsSetupError("Failed to detect Clang when checking "
"LLVM_INSTALL_DIR, CLANG_INSTALL_DIR, llvm-config")
- update_env_path(additionalPaths)
+ update_env_path(additional_paths)
build_name = "py{}-qt{}-{}-{}".format(py_version, qt_version,
platform.architecture()[0], build_type.lower())
@@ -784,7 +784,7 @@ class pyside_build(_build):
log.info("OpenSSL dll directory: {}".format(OPTION_OPENSSL))
if sys.platform == 'darwin':
pyside_macos_deployment_target = (
- pyside_build.macos_pyside_min_deployment_target()
+ PysideBuild.macos_pyside_min_deployment_target()
)
log.info("MACOSX_DEPLOYMENT_TARGET set to: {}".format(
pyside_macos_deployment_target))
@@ -803,7 +803,7 @@ class pyside_build(_build):
if not OPTION_ONLYPACKAGE:
# Build extensions
- for ext in containedModules:
+ for ext in contained_modules:
self.build_extension(ext)
if OPTION_BUILDTESTS:
@@ -854,7 +854,7 @@ class pyside_build(_build):
Otherwise use the maximum of the above mentioned two values.
"""
python_target = get_config_var('MACOSX_DEPLOYMENT_TARGET') or None
- qt_target = pyside_build.macos_qt_min_deployment_target()
+ qt_target = PysideBuild.macos_qt_min_deployment_target()
setup_target = OPTION_MACOS_DEPLOYMENT_TARGET
qt_target_split = [int(x) for x in qt_target.split('.')]
@@ -889,7 +889,7 @@ class pyside_build(_build):
@staticmethod
@memoize
def macos_plat_name():
- deployment_target = pyside_build.macos_pyside_min_deployment_target()
+ deployment_target = PysideBuild.macos_pyside_min_deployment_target()
# Example triple "macosx-10.12-x86_64".
plat = get_platform().split("-")
plat_name = "{}-{}-{}".format(plat[0], deployment_target, plat[2])
@@ -959,14 +959,14 @@ class pyside_build(_build):
cmake_cmd.append("-DPYTHON_INCLUDE_DIR={}".format(self.py_include_dir))
cmake_cmd.append("-DPYTHON_LIBRARY={}".format(self.py_library))
if OPTION_MODULE_SUBSET:
- moduleSubSet = ''
+ module_sub_set = ''
for m in OPTION_MODULE_SUBSET.split(','):
if m.startswith('Qt'):
m = m[2:]
- if moduleSubSet:
- moduleSubSet += ';'
- moduleSubSet += m
- cmake_cmd.append("-DMODULES={}".format(moduleSubSet))
+ if module_sub_set:
+ module_sub_set += ';'
+ module_sub_set += m
+ cmake_cmd.append("-DMODULES={}".format(module_sub_set))
if OPTION_SKIP_MODULES:
skip_modules = ''
for m in OPTION_SKIP_MODULES.split(','):
@@ -977,7 +977,7 @@ class pyside_build(_build):
skip_modules += m
cmake_cmd.append("-DSKIP_MODULES={}".format(skip_modules))
# Add source location for generating documentation
- cmake_src_dir = OPTION_QT_SRC if OPTION_QT_SRC else qtSrcDir
+ cmake_src_dir = OPTION_QT_SRC if OPTION_QT_SRC else qt_src_dir
cmake_cmd.append("-DQT_SRC_DIR={}".format(cmake_src_dir))
log.info("Qt Source dir: {}".format(cmake_src_dir))
@@ -1066,7 +1066,7 @@ class pyside_build(_build):
# Doing so could break the detected clang include paths
# for example.
deployment_target = \
- pyside_build.macos_pyside_min_deployment_target()
+ PysideBuild.macos_pyside_min_deployment_target()
cmake_cmd.append("-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(
deployment_target))
os.environ['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
@@ -1148,7 +1148,7 @@ class pyside_build(_build):
os.chdir(self.script_dir)
if sys.platform == "win32":
- vars['dbgPostfix'] = OPTION_DEBUG and "_d" or ""
+ vars['dbg_postfix'] = OPTION_DEBUG and "_d" or ""
return prepare_packages_win32(self, vars)
else:
return prepare_packages_posix(self, vars)
@@ -1300,13 +1300,13 @@ except IOError:
cmd_class_dict = {
- 'build': pyside_build,
- 'build_py': pyside_build_py,
- 'build_ext': pyside_build_ext,
- 'bdist_egg': pyside_bdist_egg,
- 'develop': pyside_develop,
- 'install': pyside_install,
- 'install_lib': pyside_install_lib
+ 'build': PysideBuild,
+ 'build_py': PysideBuildPy,
+ 'build_ext': PysideBuildExt,
+ 'bdist_egg': PysideBdistEgg,
+ 'develop': PysideDevelop,
+ 'install': PysideInstall,
+ 'install_lib': PysideInstallLib
}
if wheel_module_exists:
- cmd_class_dict['bdist_wheel'] = pyside_build_wheel
+ cmd_class_dict['bdist_wheel'] = PysideBuildWheel
diff --git a/build_scripts/qtinfo.py b/build_scripts/qtinfo.py
index e22bc2db..fbe8e68a 100644
--- a/build_scripts/qtinfo.py
+++ b/build_scripts/qtinfo.py
@@ -54,73 +54,73 @@ class QtInfo(object):
# Dict to cache mkspecs variables.
self._mkspecs_dict = {}
# Initialize the properties.
- self._initProperties()
+ self._init_properties()
- def getQMakeCommand(self):
+ def get_qmake_command(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 get_version(self):
+ return self.get_property("QT_VERSION")
- def getBinsPath(self):
- return self.getProperty("QT_INSTALL_BINS")
+ def get_bins_path(self):
+ return self.get_property("QT_INSTALL_BINS")
- def getLibsPath(self):
- return self.getProperty("QT_INSTALL_LIBS")
+ def get_libs_path(self):
+ return self.get_property("QT_INSTALL_LIBS")
- def getLibsExecsPath(self):
- return self.getProperty("QT_INSTALL_LIBEXECS")
+ def get_libs_execs_path(self):
+ return self.get_property("QT_INSTALL_LIBEXECS")
- def getPluginsPath(self):
- return self.getProperty("QT_INSTALL_PLUGINS")
+ def get_plugins_path(self):
+ return self.get_property("QT_INSTALL_PLUGINS")
- def getPrefixPath(self):
- return self.getProperty("QT_INSTALL_PREFIX")
+ def get_prefix_path(self):
+ return self.get_property("QT_INSTALL_PREFIX")
- def getImportsPath(self):
- return self.getProperty("QT_INSTALL_IMPORTS")
+ def get_imports_path(self):
+ return self.get_property("QT_INSTALL_IMPORTS")
- def getTranslationsPath(self):
- return self.getProperty("QT_INSTALL_TRANSLATIONS")
+ def get_translations_path(self):
+ return self.get_property("QT_INSTALL_TRANSLATIONS")
- def getHeadersPath(self):
- return self.getProperty("QT_INSTALL_HEADERS")
+ def get_headers_path(self):
+ return self.get_property("QT_INSTALL_HEADERS")
- def getDocsPath(self):
- return self.getProperty("QT_INSTALL_DOCS")
+ def get_docs_path(self):
+ return self.get_property("QT_INSTALL_DOCS")
- def getQmlPath(self):
- return self.getProperty("QT_INSTALL_QML")
+ def get_qml_path(self):
+ return self.get_property("QT_INSTALL_QML")
- def getMacOSMinDeploymentTarget(self):
+ def get_macos_deployment_target(self):
""" Return value is a macOS version or None. """
- return self.getProperty("QMAKE_MACOSX_DEPLOYMENT_TARGET")
+ return self.get_property("QMAKE_MACOSX_DEPLOYMENT_TARGET")
- def getBuildType(self):
+ def get_build_type(self):
"""
Return value is either debug, release, debug_release, or None.
"""
- return self.getProperty("BUILD_TYPE")
+ return self.get_property("BUILD_TYPE")
- def getSrcDir(self):
+ def get_src_dir(self):
""" Return path to Qt src dir or None.. """
- return self.getProperty("QT_INSTALL_PREFIX/src")
+ return self.get_property("QT_INSTALL_PREFIX/src")
- def getProperty(self, prop_name):
+ def get_property(self, prop_name):
if prop_name not in self._query_dict:
return None
return self._query_dict[prop_name]
- def getProperties(self):
+ def get_properties(self):
return self._query_dict
- def getMkspecsVariables(self):
+ def get_mkspecs_variables(self):
return self._mkspecs_dict
- def _getQMakeOutput(self, args_list = []):
+ def _get_qmake_output(self, args_list = []):
cmd = self._qmake_command + args_list
proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, shell=False)
output = proc.communicate()[0]
@@ -133,7 +133,7 @@ class QtInfo(object):
output = output.strip()
return output
- def _parseQueryProperties(self, process_output):
+ def _parse_query_properties(self, process_output):
props = {}
if not process_output:
return props
@@ -144,11 +144,11 @@ class QtInfo(object):
props[key] = value
return props
- def _getQueryProperties(self):
- output = self._getQMakeOutput(['-query'])
- self._query_dict = self._parseQueryProperties(output)
+ def _get_query_properties(self):
+ output = self._get_qmake_output(['-query'])
+ self._query_dict = self._parse_query_properties(output)
- def _parseQtBuildType(self):
+ def _parse_qt_build_type(self):
key = 'QT_CONFIG'
if key not in self._mkspecs_dict:
return None
@@ -169,15 +169,15 @@ class QtInfo(object):
return None
- def _getOtherProperties(self):
+ def _get_other_properties(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])
+ result = self._get_qmake_output(['-query', key])
self._query_dict[key] = result
# Get mkspecs variables and cache them.
- self._getQMakeMkspecsVariables()
+ self._get_qmake_mkspecs_variables()
# Get macOS minimum deployment target.
key = 'QMAKE_MACOSX_DEPLOYMENT_TARGET'
@@ -186,22 +186,22 @@ class QtInfo(object):
# Figure out how Qt was built:
# debug mode, release mode, or both.
- build_type = self._parseQtBuildType()
+ build_type = self._parse_qt_build_type()
if build_type:
self._query_dict['BUILD_TYPE'] = build_type
- def _initProperties(self):
- self._getQueryProperties()
- self._getOtherProperties()
+ def _init_properties(self):
+ self._get_query_properties()
+ self._get_other_properties()
- def _getQMakeMkspecsVariables(self):
+ def _get_qmake_mkspecs_variables(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()]
+ qmake_output = self._get_qmake_output(['-E', temp_file_name])
+ lines = [s.strip() for s in qmake_output.splitlines()]
pattern = re.compile(r"^(.+?)=(.+?)$")
for line in lines:
found = pattern.search(line)
@@ -220,18 +220,18 @@ class QtInfo(object):
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)
+ version = property(get_version)
+ bins_dir = property(get_bins_path)
+ libs_dir = property(get_libs_path)
+ lib_execs_dir = property(get_libs_execs_path)
+ plugins_dir = property(get_plugins_path)
+ prefix_dir = property(get_prefix_path)
+ qmake_command = property(get_qmake_command)
+ imports_dir = property(get_imports_path)
+ translations_dir = property(get_translations_path)
+ headers_dir = property(get_headers_path)
+ docs_dir = property(get_docs_path)
+ qml_dir = property(get_qml_path)
+ macos_min_deployment_target = property(get_macos_deployment_target)
+ build_type = property(get_build_type)
+ src_dir = property(get_src_dir)
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 2dffd345..cca93d09 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -293,27 +293,27 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False,
make_file_writable_by_owner(dst)
else:
- linkTargetPath = os.path.realpath(src)
- if os.path.dirname(linkTargetPath) == os.path.dirname(src):
- linkTarget = os.path.basename(linkTargetPath)
- linkName = os.path.basename(src)
- currentDirectory = os.getcwd()
+ link_target_path = os.path.realpath(src)
+ if os.path.dirname(link_target_path) == os.path.dirname(src):
+ link_target = os.path.basename(link_target_path)
+ link_name = os.path.basename(src)
+ current_directory = os.getcwd()
try:
- targetDir = dst if os.path.isdir(dst) else os.path.dirname(dst)
- os.chdir(targetDir)
- if os.path.exists(linkName):
- os.remove(linkName)
- log.info("Symlinking {} -> {} in {}.".format(linkName,
- linkTarget, targetDir))
- os.symlink(linkTarget, linkName)
+ target_dir = dst if os.path.isdir(dst) else os.path.dirname(dst)
+ os.chdir(target_dir)
+ if os.path.exists(link_name):
+ os.remove(link_name)
+ log.info("Symlinking {} -> {} in {}.".format(link_name,
+ link_target, target_dir))
+ os.symlink(link_target, link_name)
except OSError:
- log.error("{} -> {}: Error creating symlink".format(linkName,
- linkTarget))
+ log.error("{} -> {}: Error creating symlink".format(link_name,
+ link_target))
finally:
- os.chdir(currentDirectory)
+ os.chdir(current_directory)
else:
log.error("{} -> {}: Can only create symlinks within the same "
- "directory".format(src, linkTargetPath))
+ "directory".format(src, link_target_path))
return dst
@@ -410,36 +410,36 @@ def make_file_writable_by_owner(path):
os.chmod(path, current_permissions | stat.S_IWUSR)
def rmtree(dirname, ignore=False):
- def handleRemoveReadonly(func, path, exc):
+ def handle_remove_readonly(func, path, exc):
excvalue = exc[1]
if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777
func(path)
else:
raise
- shutil.rmtree(dirname, ignore_errors=ignore, onerror=handleRemoveReadonly)
+ shutil.rmtree(dirname, ignore_errors=ignore, onerror=handle_remove_readonly)
def run_process_output(args, initial_env=None):
if initial_env is None:
initial_env = os.environ
- stdOut = subprocess.Popen(args, env = initial_env, universal_newlines = 1,
+ std_out = subprocess.Popen(args, env = initial_env, universal_newlines = 1,
stdout=subprocess.PIPE).stdout
result = []
- for rawLine in stdOut.readlines():
- line = rawLine if sys.version_info >= (3,) else rawLine.decode('utf-8')
+ for raw_line in std_out.readlines():
+ line = raw_line if sys.version_info >= (3,) else raw_line.decode('utf-8')
result.append(line.rstrip())
return result
def run_process(args, initial_env=None):
- def _log(buffer, checkNewLine=False):
- endsWithNewLine = False
+ def _log(buffer, check_new_line=False):
+ ends_with_new_line = False
if buffer.endswith('\n'):
- endsWithNewLine = True
- if checkNewLine and buffer.find('\n') == -1:
+ ends_with_new_line = True
+ if check_new_line and buffer.find('\n') == -1:
return buffer
lines = buffer.splitlines()
buffer = ''
- if checkNewLine and not endsWithNewLine:
+ if check_new_line and not ends_with_new_line:
buffer = lines[-1]
lines = lines[:-1]
for line in lines:
@@ -742,7 +742,7 @@ def macos_add_qt_rpath(library_path, qt_lib_dir,
rpath=qt_lib_dir, library_path=library_path))
# Find an executable specified by a glob pattern ('foo*') in the OS path
-def findGlobInPath(pattern):
+def find_glob_in_path(pattern):
result = []
if sys.platform == 'win32':
pattern += '.exe'
@@ -752,47 +752,47 @@ def findGlobInPath(pattern):
result.append(match)
return result
-# Locate the most recent version of llvmConfig in the path.
-def findLlvmConfig():
- versionRe = re.compile('(\d+)\.(\d+)\.(\d+)')
+# Locate the most recent version of llvm_config in the path.
+def find_llvm_config():
+ version_re = re.compile('(\d+)\.(\d+)\.(\d+)')
result = None
- lastVersionString = '000000'
- for llvmConfig in findGlobInPath('llvm-config*'):
+ last_version_string = '000000'
+ for llvm_config in find_glob_in_path('llvm-config*'):
try:
- output = run_process_output([llvmConfig, '--version'])
+ output = run_process_output([llvm_config, '--version'])
if output:
- match = versionRe.match(output[0])
+ match = version_re.match(output[0])
if match:
- versionString = '%02d%02d%02d' % (int(match.group(1)),
+ version_string = '%02d%02d%02d' % (int(match.group(1)),
int(match.group(2)), int(match.group(3)))
- if (versionString > lastVersionString):
- result = llvmConfig
- lastVersionString = versionString
+ if (version_string > last_version_string):
+ result = llvm_config
+ last_version_string = version_string
except OSError:
pass
return result
# Add Clang to path for Windows for the shiboken ApiExtractor tests.
# Revisit once Clang is bundled with Qt.
-def detectClang():
+def detect_clang():
source = 'LLVM_INSTALL_DIR'
- clangDir = os.environ.get(source, None)
- if not clangDir:
+ clang_dir = os.environ.get(source, None)
+ if not clang_dir:
source = 'CLANG_INSTALL_DIR'
- clangDir = os.environ.get(source, None)
- if not clangDir:
- source = findLlvmConfig()
+ clang_dir = os.environ.get(source, None)
+ if not clang_dir:
+ source = find_llvm_config()
try:
if source is not None:
output = run_process_output([source, '--prefix'])
if output:
- clangDir = output[0]
+ clang_dir = output[0]
except OSError:
pass
- if clangDir:
+ if clang_dir:
arch = '64' if sys.maxsize > 2**31-1 else '32'
- clangDir = clangDir.replace('_ARCH_', arch)
- return (clangDir, source)
+ clang_dir = clang_dir.replace('_ARCH_', arch)
+ return (clang_dir, source)
def download_and_extract_7z(fileurl, target):
""" Downloads 7z file from fileurl and extract to target """
@@ -983,35 +983,35 @@ def copy_icu_libs(destination_lib_dir):
copyfile(path, destination, force_copy_symlink=True)
# Patch the ICU libraries to contain the $ORIGIN rpath
# value, so that only the local package libraries are used.
- linuxSetRPaths(destination, '$ORIGIN')
+ linux_set_rpaths(destination, '$ORIGIN')
# Patch the QtCore library to find the copied over ICU libraries
# (if necessary).
log.info("Checking if QtCore library needs a new rpath to make it "
"work with ICU libs.")
- rpaths = linuxGetRPaths(qt_core_library_path)
- if not rpaths or not rpathsHasOrigin(rpaths):
+ rpaths = linux_get_rpaths(qt_core_library_path)
+ if not rpaths or not rpaths_has_origin(rpaths):
log.info('Patching QtCore library to contain $ORIGIN rpath.')
rpaths.insert(0, '$ORIGIN')
new_rpaths_string = ":".join(rpaths)
- linuxSetRPaths(qt_core_library_path, new_rpaths_string)
+ linux_set_rpaths(qt_core_library_path, new_rpaths_string)
-def linuxSetRPaths(executable_path, rpath_string):
+def linux_set_rpaths(executable_path, rpath_string):
""" Patches the `executable_path` with a new rpath string. """
- if not hasattr(linuxSetRPaths, "patchelf_path"):
+ if not hasattr(linux_set_rpaths, "patchelf_path"):
script_dir = os.getcwd()
patchelf_path = os.path.join(script_dir, "patchelf")
- setattr(linuxSetRPaths, "patchelf_path", patchelf_path)
+ setattr(linux_set_rpaths, "patchelf_path", patchelf_path)
- cmd = [linuxSetRPaths.patchelf_path, '--set-rpath',
+ cmd = [linux_set_rpaths.patchelf_path, '--set-rpath',
rpath_string, executable_path]
if run_process(cmd) != 0:
raise RuntimeError("Error patching rpath in {}".format(
executable_path))
-def linuxGetRPaths(executable_path):
+def linux_get_rpaths(executable_path):
"""
Returns a list of run path values embedded in the executable or just
an empty list.
@@ -1039,7 +1039,7 @@ def linuxGetRPaths(executable_path):
return rpaths
-def rpathsHasOrigin(rpaths):
+def rpaths_has_origin(rpaths):
"""
Return True if the specified list of rpaths has an "$ORIGIN" value
(aka current dir).
diff --git a/testing/runner.py b/testing/runner.py
index 945e3246..3c99df71 100644
--- a/testing/runner.py
+++ b/testing/runner.py
@@ -61,7 +61,7 @@ this_dir = os.path.dirname(this_file)
build_scripts_dir = os.path.abspath(os.path.join(this_dir, '../build_scripts'))
sys.path.append(build_scripts_dir)
-from utils import detectClang
+from utils import detect_clang
class TestRunner(object):
def __init__(self, log_entry, project, index):
@@ -74,19 +74,19 @@ class TestRunner(object):
else:
self.logfile = os.path.join(log_dir, project + ".log")
os.environ['CTEST_OUTPUT_ON_FAILURE'] = '1'
- self._setupClang()
+ self._setup_clang()
self._setup()
- def _setupClang(self):
+ def _setup_clang(self):
if sys.platform != "win32":
return
- clangDir = detectClang()
- if clangDir[0]:
- clangBinDir = os.path.join(clangDir[0], 'bin')
+ clang_dir = detect_clang()
+ if clang_dir[0]:
+ clang_bin_dir = os.path.join(clang_dir[0], 'bin')
path = os.environ.get('PATH')
- if not clangBinDir in path:
- os.environ['PATH'] = clangBinDir + os.pathsep + path
- print("Adding %s as detected by %s to PATH" % (clangBinDir, clangDir[1]))
+ if not clang_bin_dir in path:
+ os.environ['PATH'] = clang_bin_dir + os.pathsep + path
+ print("Adding %s as detected by %s to PATH" % (clang_bin_dir, clang_dir[1]))
def _find_ctest(self):
"""