aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-03-04 17:16:11 -0500
committerEli Schwartz <eschwartz@archlinux.org>2021-03-04 17:16:11 -0500
commit6a0fabc6472f49621260de215f128a31ae70219b (patch)
tree6a67908358a2c5e5baa215fe0201dfe213dd8a01 /mesonbuild/dependencies
parent4340bf34faca7eed8076ba4c388fbe15355f2183 (diff)
downloadmeson-6a0fabc6472f49621260de215f128a31ae70219b.zip
meson-6a0fabc6472f49621260de215f128a31ae70219b.tar.gz
meson-6a0fabc6472f49621260de215f128a31ae70219b.tar.bz2
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/base.py116
-rw-r--r--mesonbuild/dependencies/boost.py32
-rw-r--r--mesonbuild/dependencies/cuda.py24
-rw-r--r--mesonbuild/dependencies/dev.py20
-rw-r--r--mesonbuild/dependencies/hdf5.py12
-rw-r--r--mesonbuild/dependencies/misc.py20
-rw-r--r--mesonbuild/dependencies/ui.py8
7 files changed, 116 insertions, 116 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index bd94648..4410b67 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -88,12 +88,12 @@ def find_external_program(env: Environment, for_machine: MachineChoice, name: st
# We never fallback if the user-specified option is no good, so
# stop returning options.
return
- mlog.debug('{} binary missing from cross or native file, or env var undefined.'.format(display_name))
+ mlog.debug(f'{display_name} binary missing from cross or native file, or env var undefined.')
# Fallback on hard-coded defaults, if a default binary is allowed for use
# with cross targets, or if this is not a cross target
if allow_default_for_cross or not (for_machine is MachineChoice.HOST and env.is_cross_build(for_machine)):
for potential_path in default_names:
- mlog.debug('Trying a default {} fallback at'.format(display_name), potential_path)
+ mlog.debug(f'Trying a default {display_name} fallback at', potential_path)
yield ExternalProgram(potential_path, silent=True)
else:
mlog.debug('Default target is not allowed for cross use')
@@ -193,10 +193,10 @@ class Dependency:
return []
def get_pkgconfig_variable(self, variable_name: str, kwargs: T.Dict[str, T.Any]) -> str:
- raise DependencyException('{!r} is not a pkgconfig dependency'.format(self.name))
+ raise DependencyException(f'{self.name!r} is not a pkgconfig dependency')
def get_configtool_variable(self, variable_name):
- raise DependencyException('{!r} is not a config-tool dependency'.format(self.name))
+ raise DependencyException(f'{self.name!r} is not a config-tool dependency')
def get_partial_dependency(self, *, compile_args: bool = False,
link_args: bool = False, links: bool = False,
@@ -238,7 +238,7 @@ class Dependency:
pkgconfig_define: T.Optional[T.List[str]] = None) -> T.Union[str, T.List[str]]:
if default_value is not None:
return default_value
- raise DependencyException('No default provided for dependency {!r}, which is not pkg-config, cmake, or config-tool based.'.format(self))
+ raise DependencyException(f'No default provided for dependency {self!r}, which is not pkg-config, cmake, or config-tool based.')
def generate_system_dependency(self, include_type: str) -> T.Type['Dependency']:
new_dep = copy.deepcopy(self)
@@ -312,7 +312,7 @@ class InternalDependency(Dependency):
val = self.variables.get(internal, default_value)
if val is not None:
return val
- raise DependencyException('Could not get an internal variable and no default provided for {!r}'.format(self))
+ raise DependencyException(f'Could not get an internal variable and no default provided for {self!r}')
def generate_link_whole_dependency(self) -> T.Type['Dependency']:
new_dep = copy.deepcopy(self)
@@ -399,10 +399,10 @@ class ExternalDependency(Dependency, HasNativeKwarg):
found_msg = ['Dependency', mlog.bold(self.name), 'found:']
found_msg += [mlog.red('NO'),
'found', mlog.normal_cyan(self.version), 'but need:',
- mlog.bold(', '.join(["'{}'".format(e) for e in not_found]))]
+ mlog.bold(', '.join([f"'{e}'" for e in not_found]))]
if found:
found_msg += ['; matched:',
- ', '.join(["'{}'".format(e) for e in found])]
+ ', '.join([f"'{e}'" for e in found])]
mlog.log(*found_msg)
if self.required:
@@ -518,9 +518,9 @@ class ConfigToolDependency(ExternalDependency):
if self.config is None:
found_msg.append(mlog.red('NO'))
if version is not None and req_version is not None:
- found_msg.append('found {!r} but need {!r}'.format(version, req_version))
+ found_msg.append(f'found {version!r} but need {req_version!r}')
elif req_version:
- found_msg.append('need {!r}'.format(req_version))
+ found_msg.append(f'need {req_version!r}')
else:
found_msg += [mlog.green('YES'), '({})'.format(' '.join(self.config)), version]
@@ -543,14 +543,14 @@ class ConfigToolDependency(ExternalDependency):
return [DependencyMethods.AUTO, DependencyMethods.CONFIG_TOOL]
def get_configtool_variable(self, variable_name):
- p, out, _ = Popen_safe(self.config + ['--{}'.format(variable_name)])
+ p, out, _ = Popen_safe(self.config + [f'--{variable_name}'])
if p.returncode != 0:
if self.required:
raise DependencyException(
'Could not get variable "{}" for dependency {}'.format(
variable_name, self.name))
variable = out.strip()
- mlog.debug('Got config-tool variable {} : {}'.format(variable_name, variable))
+ mlog.debug(f'Got config-tool variable {variable_name} : {variable}')
return variable
def log_tried(self):
@@ -575,7 +575,7 @@ class ConfigToolDependency(ExternalDependency):
self.required = restore
if default_value is not None:
return default_value
- raise DependencyException('Could not get config-tool variable and no default provided for {!r}'.format(self))
+ raise DependencyException(f'Could not get config-tool variable and no default provided for {self!r}')
class PkgConfigDependency(ExternalDependency):
@@ -644,7 +644,7 @@ class PkgConfigDependency(ExternalDependency):
# Fetch the libraries and library paths needed for using this
self._set_libs()
except DependencyException as e:
- mlog.debug("pkg-config error with '%s': %s" % (name, e))
+ mlog.debug(f"pkg-config error with '{name}': {e}")
if self.required:
raise
else:
@@ -663,7 +663,7 @@ class PkgConfigDependency(ExternalDependency):
p, out, err = Popen_safe(cmd, env=env)
rc, out, err = p.returncode, out.strip(), err.strip()
call = ' '.join(cmd)
- mlog.debug("Called `{}` -> {}\n{}".format(call, rc, out))
+ mlog.debug(f"Called `{call}` -> {rc}\n{out}")
return rc, out, err
@staticmethod
@@ -937,9 +937,9 @@ class PkgConfigDependency(ExternalDependency):
if 'default' in kwargs:
variable = kwargs['default']
else:
- mlog.warning("pkgconfig variable '%s' not defined for dependency %s." % (variable_name, self.name))
+ mlog.warning(f"pkgconfig variable '{variable_name}' not defined for dependency {self.name}.")
- mlog.debug('Got pkgconfig variable %s : %s' % (variable_name, variable))
+ mlog.debug(f'Got pkgconfig variable {variable_name} : {variable}')
return variable
@staticmethod
@@ -948,7 +948,7 @@ class PkgConfigDependency(ExternalDependency):
def check_pkgconfig(self, pkgbin):
if not pkgbin.found():
- mlog.log('Did not find pkg-config by name {!r}'.format(pkgbin.name))
+ mlog.log(f'Did not find pkg-config by name {pkgbin.name!r}')
return None
try:
p, out = Popen_safe(pkgbin.get_command() + ['--version'])[0:2]
@@ -1022,7 +1022,7 @@ class PkgConfigDependency(ExternalDependency):
pass
if default_value is not None:
return default_value
- raise DependencyException('Could not get pkg-config variable and no default provided for {!r}'.format(self))
+ raise DependencyException(f'Could not get pkg-config variable and no default provided for {self!r}')
class CMakeDependency(ExternalDependency):
# The class's copy of the CMake path. Avoids having to search for it
@@ -1035,7 +1035,7 @@ class CMakeDependency(ExternalDependency):
class_working_generator = None
def _gen_exception(self, msg):
- return DependencyException('Dependency {} not found: {}'.format(self.name, msg))
+ return DependencyException(f'Dependency {self.name} not found: {msg}')
def _main_cmake_file(self) -> str:
return 'CMakeLists.txt'
@@ -1109,7 +1109,7 @@ class CMakeDependency(ExternalDependency):
self.cmakebin = CMakeExecutor(environment, CMakeDependency.class_cmake_version, self.for_machine, silent=self.silent)
if not self.cmakebin.found():
self.cmakebin = None
- msg = 'No CMake binary for machine {} not found. Giving up.'.format(self.for_machine)
+ msg = f'No CMake binary for machine {self.for_machine} not found. Giving up.'
if self.required:
raise DependencyException(msg)
mlog.debug(msg)
@@ -1179,8 +1179,8 @@ class CMakeDependency(ExternalDependency):
CMakeDependency.class_working_generator = i
break
- mlog.debug('CMake failed to gather system information for generator {} with error code {}'.format(i, ret1))
- mlog.debug('OUT:\n{}\n\n\nERR:\n{}\n\n'.format(out1, err1))
+ mlog.debug(f'CMake failed to gather system information for generator {i} with error code {ret1}')
+ mlog.debug(f'OUT:\n{out1}\n\n\nERR:\n{err1}\n\n')
# Check if any generator succeeded
if ret1 != 0:
@@ -1333,7 +1333,7 @@ class CMakeDependency(ExternalDependency):
return True
# Check the environment path
- env_path = os.environ.get('{}_DIR'.format(name))
+ env_path = os.environ.get(f'{name}_DIR')
if env_path and find_module(env_path):
return True
@@ -1367,9 +1367,9 @@ class CMakeDependency(ExternalDependency):
# Prepare options
cmake_opts = []
- cmake_opts += ['-DNAME={}'.format(name)]
+ cmake_opts += [f'-DNAME={name}']
cmake_opts += ['-DARCHS={}'.format(';'.join(self.cmakeinfo['archs']))]
- cmake_opts += ['-DVERSION={}'.format(package_version)]
+ cmake_opts += [f'-DVERSION={package_version}']
cmake_opts += ['-DCOMPS={}'.format(';'.join([x[0] for x in comp_mapped]))]
cmake_opts += args
cmake_opts += self.traceparser.trace_args()
@@ -1387,8 +1387,8 @@ class CMakeDependency(ExternalDependency):
CMakeDependency.class_working_generator = i
break
- mlog.debug('CMake failed for generator {} and package {} with error code {}'.format(i, name, ret1))
- mlog.debug('OUT:\n{}\n\n\nERR:\n{}\n\n'.format(out1, err1))
+ mlog.debug(f'CMake failed for generator {i} and package {name} with error code {ret1}')
+ mlog.debug(f'OUT:\n{out1}\n\n\nERR:\n{err1}\n\n')
# Check if any generator succeeded
if ret1 != 0:
@@ -1429,8 +1429,8 @@ class CMakeDependency(ExternalDependency):
for i in self.traceparser.targets:
tg = i.lower()
lname = name.lower()
- if '{}::{}'.format(lname, lname) == tg or lname == tg.replace('::', ''):
- mlog.debug('Guessed CMake target \'{}\''.format(i))
+ if f'{lname}::{lname}' == tg or lname == tg.replace('::', ''):
+ mlog.debug(f'Guessed CMake target \'{i}\'')
modules = [(i, True)]
autodetected_module_list = True
break
@@ -1443,12 +1443,12 @@ class CMakeDependency(ExternalDependency):
# Try to use old style variables if no module is specified
if len(libs) > 0:
- self.compile_args = list(map(lambda x: '-I{}'.format(x), incDirs)) + defs
+ self.compile_args = list(map(lambda x: f'-I{x}', incDirs)) + defs
self.link_args = libs
- mlog.debug('using old-style CMake variables for dependency {}'.format(name))
- mlog.debug('Include Dirs: {}'.format(incDirs))
- mlog.debug('Compiler Definitions: {}'.format(defs))
- mlog.debug('Libraries: {}'.format(libs))
+ mlog.debug(f'using old-style CMake variables for dependency {name}')
+ mlog.debug(f'Include Dirs: {incDirs}')
+ mlog.debug(f'Compiler Definitions: {defs}')
+ mlog.debug(f'Libraries: {libs}')
return
# Even the old-style approach failed. Nothing else we can do here
@@ -1520,20 +1520,20 @@ class CMakeDependency(ExternalDependency):
if 'RELEASE' in cfgs:
cfg = 'RELEASE'
- if 'IMPORTED_IMPLIB_{}'.format(cfg) in tgt.properties:
- libraries += [x for x in tgt.properties['IMPORTED_IMPLIB_{}'.format(cfg)] if x]
+ if f'IMPORTED_IMPLIB_{cfg}' in tgt.properties:
+ libraries += [x for x in tgt.properties[f'IMPORTED_IMPLIB_{cfg}'] if x]
elif 'IMPORTED_IMPLIB' in tgt.properties:
libraries += [x for x in tgt.properties['IMPORTED_IMPLIB'] if x]
- elif 'IMPORTED_LOCATION_{}'.format(cfg) in tgt.properties:
- libraries += [x for x in tgt.properties['IMPORTED_LOCATION_{}'.format(cfg)] if x]
+ elif f'IMPORTED_LOCATION_{cfg}' in tgt.properties:
+ libraries += [x for x in tgt.properties[f'IMPORTED_LOCATION_{cfg}'] if x]
elif 'IMPORTED_LOCATION' in tgt.properties:
libraries += [x for x in tgt.properties['IMPORTED_LOCATION'] if x]
if 'INTERFACE_LINK_LIBRARIES' in tgt.properties:
otherDeps += [x for x in tgt.properties['INTERFACE_LINK_LIBRARIES'] if x]
- if 'IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg) in tgt.properties:
- otherDeps += [x for x in tgt.properties['IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg)] if x]
+ if f'IMPORTED_LINK_DEPENDENT_LIBRARIES_{cfg}' in tgt.properties:
+ otherDeps += [x for x in tgt.properties[f'IMPORTED_LINK_DEPENDENT_LIBRARIES_{cfg}'] if x]
elif 'IMPORTED_LINK_DEPENDENT_LIBRARIES' in tgt.properties:
otherDeps += [x for x in tgt.properties['IMPORTED_LINK_DEPENDENT_LIBRARIES'] if x]
@@ -1551,7 +1551,7 @@ class CMakeDependency(ExternalDependency):
# as we do not have a compiler environment available to us, we cannot do the
# same, but must assume any bare argument passed which is not also a CMake
# target must be a system library we should try to link against
- libraries += ["{}.lib".format(j)]
+ libraries += [f"{j}.lib"]
else:
mlog.warning('CMake: Dependency', mlog.bold(j), 'for', mlog.bold(name), 'target', mlog.bold(self._original_module_name(curr)), 'was not found')
@@ -1563,16 +1563,16 @@ class CMakeDependency(ExternalDependency):
compileOptions = sorted(set(compileOptions))
libraries = sorted(set(libraries))
- mlog.debug('Include Dirs: {}'.format(incDirs))
- mlog.debug('Compiler Definitions: {}'.format(compileDefinitions))
- mlog.debug('Compiler Options: {}'.format(compileOptions))
- mlog.debug('Libraries: {}'.format(libraries))
+ mlog.debug(f'Include Dirs: {incDirs}')
+ mlog.debug(f'Compiler Definitions: {compileDefinitions}')
+ mlog.debug(f'Compiler Options: {compileOptions}')
+ mlog.debug(f'Libraries: {libraries}')
- self.compile_args = compileOptions + compileDefinitions + ['-I{}'.format(x) for x in incDirs]
+ self.compile_args = compileOptions + compileDefinitions + [f'-I{x}' for x in incDirs]
self.link_args = libraries
def _get_build_dir(self) -> Path:
- build_dir = Path(self.cmake_root_dir) / 'cmake_{}'.format(self.name)
+ build_dir = Path(self.cmake_root_dir) / f'cmake_{self.name}'
build_dir.mkdir(parents=True, exist_ok=True)
return build_dir
@@ -1647,7 +1647,7 @@ class CMakeDependency(ExternalDependency):
return v
if default_value is not None:
return default_value
- raise DependencyException('Could not get cmake variable and no default provided for {!r}'.format(self))
+ raise DependencyException(f'Could not get cmake variable and no default provided for {self!r}')
class DubDependency(ExternalDependency):
class_dubbin = None
@@ -1759,7 +1759,7 @@ class DubDependency(ExternalDependency):
for target in description['targets']:
if target['rootPackage'] in packages:
add_lib_args('libs', target)
- add_lib_args('libs-{}'.format(platform.machine()), target)
+ add_lib_args(f'libs-{platform.machine()}', target)
for file in target['buildSettings']['linkerFiles']:
lib_path = self._find_right_lib_path(file, comp, description)
if lib_path:
@@ -2007,7 +2007,7 @@ class ExternalProgram:
return commands + [script]
except Exception as e:
mlog.debug(e)
- mlog.debug('Unusable script {!r}'.format(script))
+ mlog.debug(f'Unusable script {script!r}')
return None
def _is_executable(self, path):
@@ -2034,7 +2034,7 @@ class ExternalProgram:
else:
if mesonlib.is_windows():
for ext in self.windows_exts:
- trial_ext = '{}.{}'.format(trial, ext)
+ trial_ext = f'{trial}.{ext}'
if os.path.exists(trial_ext):
return [trial_ext]
return None
@@ -2069,7 +2069,7 @@ class ExternalProgram:
# but many people do it because it works in the MinGW shell.
if os.path.isabs(name):
for ext in self.windows_exts:
- command = '{}.{}'.format(name, ext)
+ command = f'{name}.{ext}'
if os.path.exists(command):
return [command]
# On Windows, interpreted scripts must have an extension otherwise they
@@ -2217,7 +2217,7 @@ class ExtraFrameworkDependency(ExternalDependency):
if not paths:
paths = self.system_framework_paths
for p in paths:
- mlog.debug('Looking for framework {} in {}'.format(name, p))
+ mlog.debug(f'Looking for framework {name} in {p}')
# We need to know the exact framework path because it's used by the
# Qt5 dependency class, and for setting the include path. We also
# want to avoid searching in an invalid framework path which wastes
@@ -2410,7 +2410,7 @@ def find_external_dependency(name, env, kwargs):
raise DependencyException('Keyword "method" must be a string.')
lname = name.lower()
if lname not in _packages_accept_language and 'language' in kwargs:
- raise DependencyException('%s dependency does not accept "language" keyword argument' % (name, ))
+ raise DependencyException(f'{name} dependency does not accept "language" keyword argument')
if not isinstance(kwargs.get('version', ''), (str, list)):
raise DependencyException('Keyword "Version" must be string or list.')
@@ -2468,7 +2468,7 @@ def find_external_dependency(name, env, kwargs):
tried = ''
mlog.log(type_text, mlog.bold(display_name), details + 'found:', mlog.red('NO'),
- '(tried {})'.format(tried) if tried else '')
+ f'(tried {tried})' if tried else '')
if required:
# if an exception occurred with the first detection method, re-raise it
@@ -2572,7 +2572,7 @@ def strip_system_libdirs(environment, for_machine: MachineChoice, link_args):
in the system path, and a different version not in the system path if they
want to link against the non-system path version.
"""
- exclude = {'-L{}'.format(p) for p in environment.get_compiler_system_dirs(for_machine)}
+ exclude = {f'-L{p}' for p in environment.get_compiler_system_dirs(for_machine)}
return [l for l in link_args if l not in exclude]
@@ -2582,7 +2582,7 @@ def process_method_kw(possible: T.Iterable[DependencyMethods], kwargs) -> T.List
return [method]
# TODO: try/except?
if method not in [e.value for e in DependencyMethods]:
- raise DependencyException('method {!r} is invalid'.format(method))
+ raise DependencyException(f'method {method!r} is invalid')
method = DependencyMethods(method)
# This sets per-tool config methods which are deprecated to to the new
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 8fb258e..2c735bc 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -91,11 +91,11 @@ class BoostIncludeDir():
major = int(self.version_int / 100000)
minor = int((self.version_int / 100) % 1000)
patch = int(self.version_int % 100)
- self.version = '{}.{}.{}'.format(major, minor, patch)
- self.version_lib = '{}_{}'.format(major, minor)
+ self.version = f'{major}.{minor}.{patch}'
+ self.version_lib = f'{major}_{minor}'
def __repr__(self) -> str:
- return '<BoostIncludeDir: {} -- {}>'.format(self.version, self.path)
+ return f'<BoostIncludeDir: {self.version} -- {self.path}>'
def __lt__(self, other: object) -> bool:
if isinstance(other, BoostIncludeDir):
@@ -152,7 +152,7 @@ class BoostLibraryFile():
elif self.nvsuffix in ['a', 'lib']:
self.static = True
else:
- raise DependencyException('Unable to process library extension "{}" ({})'.format(self.nvsuffix, self.path))
+ raise DependencyException(f'Unable to process library extension "{self.nvsuffix}" ({self.path})')
# boost_.lib is the dll import library
if self.basename.startswith('boost_') and self.nvsuffix == 'lib':
@@ -187,7 +187,7 @@ class BoostLibraryFile():
self.toolset = i
def __repr__(self) -> str:
- return '<LIB: {} {:<32} {}>'.format(self.abitag, self.mod_name, self.path)
+ return f'<LIB: {self.abitag} {self.mod_name:<32} {self.path}>'
def __lt__(self, other: object) -> bool:
if isinstance(other, BoostLibraryFile):
@@ -320,7 +320,7 @@ class BoostLibraryFile():
elif vscrt in ['/MTd', '-MTd']:
return (self.runtime_static or not self.static) and self.runtime_debug
- mlog.warning('Boost: unknow vscrt tag {}. This may cause the compilation to fail. Please consider reporting this as a bug.'.format(vscrt), once=True)
+ mlog.warning(f'Boost: unknow vscrt tag {vscrt}. This may cause the compilation to fail. Please consider reporting this as a bug.', once=True)
return True
def get_compiler_args(self) -> T.List[str]:
@@ -386,7 +386,7 @@ class BoostDependency(ExternalDependency):
roots = list(mesonlib.OrderedSet(roots))
for j in roots:
# 1. Look for the boost headers (boost/version.hpp)
- mlog.debug('Checking potential boost root {}'.format(j.as_posix()))
+ mlog.debug(f'Checking potential boost root {j.as_posix()}')
inc_dirs = self.detect_inc_dirs(j)
inc_dirs = sorted(inc_dirs, reverse=True) # Prefer the newer versions
@@ -419,8 +419,8 @@ class BoostDependency(ExternalDependency):
raise DependencyException('Paths given for boost_includedir and boost_librarydir in machine file must be absolute')
mlog.debug('Trying to find boost with:')
- mlog.debug(' - boost_includedir = {}'.format(inc_dir))
- mlog.debug(' - boost_librarydir = {}'.format(lib_dir))
+ mlog.debug(f' - boost_includedir = {inc_dir}')
+ mlog.debug(f' - boost_librarydir = {lib_dir}')
return self.detect_split_root(inc_dir, lib_dir)
@@ -447,7 +447,7 @@ class BoostDependency(ExternalDependency):
for i in lib_dirs:
libs = self.detect_libraries(i)
if libs:
- mlog.debug(' - found boost library dir: {}'.format(i))
+ mlog.debug(f' - found boost library dir: {i}')
# mlog.debug(' - raw library list:')
# for j in libs:
# mlog.debug(' - {}'.format(j))
@@ -456,12 +456,12 @@ class BoostDependency(ExternalDependency):
modules = ['boost_' + x for x in self.modules]
for inc in inc_dirs:
- mlog.debug(' - found boost {} include dir: {}'.format(inc.version, inc.path))
+ mlog.debug(f' - found boost {inc.version} include dir: {inc.path}')
f_libs = self.filter_libraries(libs, inc.version_lib)
mlog.debug(' - filtered library list:')
for j in f_libs:
- mlog.debug(' - {}'.format(j))
+ mlog.debug(f' - {j}')
# 3. Select the libraries matching the requested modules
not_found = [] # type: T.List[str]
@@ -505,14 +505,14 @@ class BoostDependency(ExternalDependency):
self.compile_args += self._extra_compile_args()
self.compile_args = list(mesonlib.OrderedSet(self.compile_args))
self.link_args = link_args
- mlog.debug(' - final compile args: {}'.format(self.compile_args))
- mlog.debug(' - final link args: {}'.format(self.link_args))
+ mlog.debug(f' - final compile args: {self.compile_args}')
+ mlog.debug(f' - final link args: {self.link_args}')
return True
# in case we missed something log it and try again
mlog.debug(' - NOT found:')
for mod in not_found:
- mlog.debug(' - {}'.format(mod))
+ mlog.debug(f' - {mod}')
return False
@@ -720,7 +720,7 @@ class BoostDependency(ExternalDependency):
raw = hfile.read_text()
m = re.search(r'#define\s+BOOST_VERSION\s+([0-9]+)', raw)
if not m:
- mlog.debug('Failed to extract version information from {}'.format(hfile))
+ mlog.debug(f'Failed to extract version information from {hfile}')
return BoostIncludeDir(hfile.parents[1], 0)
return BoostIncludeDir(hfile.parents[1], int(m.group(1)))
diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py
index 6d17b90..a8325ff 100644
--- a/mesonbuild/dependencies/cuda.py
+++ b/mesonbuild/dependencies/cuda.py
@@ -33,7 +33,7 @@ class CudaDependency(ExternalDependency):
compilers = environment.coredata.compilers[self.get_for_machine_from_kwargs(kwargs)]
language = self._detect_language(compilers)
if language not in self.supported_languages:
- raise DependencyException('Language \'{}\' is not supported by the CUDA Toolkit. Supported languages are {}.'.format(language, self.supported_languages))
+ raise DependencyException(f'Language \'{language}\' is not supported by the CUDA Toolkit. Supported languages are {self.supported_languages}.')
super().__init__('cuda', environment, kwargs, language=language)
self.requested_modules = self.get_requested(kwargs)
@@ -45,13 +45,13 @@ class CudaDependency(ExternalDependency):
return
if not os.path.isabs(self.cuda_path):
- raise DependencyException('CUDA Toolkit path must be absolute, got \'{}\'.'.format(self.cuda_path))
+ raise DependencyException(f'CUDA Toolkit path must be absolute, got \'{self.cuda_path}\'.')
# nvcc already knows where to find the CUDA Toolkit, but if we're compiling
# a mixed C/C++/CUDA project, we still need to make the include dir searchable
if self.language != 'cuda' or len(compilers) > 1:
self.incdir = os.path.join(self.cuda_path, 'include')
- self.compile_args += ['-I{}'.format(self.incdir)]
+ self.compile_args += [f'-I{self.incdir}']
if self.language != 'cuda':
arch_libdir = self._detect_arch_libdir()
@@ -81,11 +81,11 @@ class CudaDependency(ExternalDependency):
# make sure nvcc version satisfies specified version requirements
(found_some, not_found, found) = mesonlib.version_compare_many(nvcc_version, version_reqs)
if not_found:
- msg = 'The current nvcc version {} does not satisfy the specified CUDA Toolkit version requirements {}.'.format(nvcc_version, version_reqs)
+ msg = f'The current nvcc version {nvcc_version} does not satisfy the specified CUDA Toolkit version requirements {version_reqs}.'
return self._report_dependency_error(msg, (None, None, False))
# use nvcc version to find a matching CUDA Toolkit
- version_reqs = ['={}'.format(nvcc_version)]
+ version_reqs = [f'={nvcc_version}']
else:
nvcc_version = None
@@ -99,7 +99,7 @@ class CudaDependency(ExternalDependency):
platform_msg = 'set the CUDA_PATH environment variable' if self._is_windows() \
else 'set the CUDA_PATH environment variable/create the \'/usr/local/cuda\' symbolic link'
- msg = 'Please specify the desired CUDA Toolkit version (e.g. dependency(\'cuda\', version : \'>=10.1\')) or {} to point to the location of your desired version.'.format(platform_msg)
+ msg = f'Please specify the desired CUDA Toolkit version (e.g. dependency(\'cuda\', version : \'>=10.1\')) or {platform_msg} to point to the location of your desired version.'
return self._report_dependency_error(msg, (None, None, False))
def _find_matching_toolkit(self, paths, version_reqs, nvcc_version):
@@ -108,10 +108,10 @@ class CudaDependency(ExternalDependency):
defaults, rest = mesonlib.partition(lambda t: not t[2], paths)
defaults = list(defaults)
paths = defaults + sorted(rest, key=lambda t: mesonlib.Version(t[1]), reverse=True)
- mlog.debug('Search paths: {}'.format(paths))
+ mlog.debug(f'Search paths: {paths}')
if nvcc_version and defaults:
- default_src = "the {} environment variable".format(self.env_var) if self.env_var else "the \'/usr/local/cuda\' symbolic link"
+ default_src = f"the {self.env_var} environment variable" if self.env_var else "the \'/usr/local/cuda\' symbolic link"
nvcc_warning = 'The default CUDA Toolkit as designated by {} ({}) doesn\'t match the current nvcc version {} and will be ignored.'.format(default_src, os.path.realpath(defaults[0][0]), nvcc_version)
else:
nvcc_warning = None
@@ -168,7 +168,7 @@ class CudaDependency(ExternalDependency):
if m:
return m.group(1)
else:
- mlog.warning('Could not detect CUDA Toolkit version for {}'.format(path))
+ mlog.warning(f'Could not detect CUDA Toolkit version for {path}')
except Exception as e:
mlog.warning('Could not detect CUDA Toolkit version for {}: {}'.format(path, str(e)))
@@ -188,7 +188,7 @@ class CudaDependency(ExternalDependency):
# use // for floor instead of / which produces a float
major = vers_int // 1000 # type: int
minor = (vers_int - major * 1000) // 10 # type: int
- return '{}.{}'.format(major, minor)
+ return f'{major}.{minor}'
return None
def _read_toolkit_version_txt(self, path: str) -> T.Optional[str]:
@@ -238,10 +238,10 @@ class CudaDependency(ExternalDependency):
for module in self.requested_modules:
args = self.clib_compiler.find_library(module, self.env, [self.libdir] if self.libdir else [])
if args is None:
- self._report_dependency_error('Couldn\'t find requested CUDA module \'{}\''.format(module))
+ self._report_dependency_error(f'Couldn\'t find requested CUDA module \'{module}\'')
all_found = False
else:
- mlog.debug('Link args for CUDA module \'{}\' are {}'.format(module, args))
+ mlog.debug(f'Link args for CUDA module \'{module}\' are {args}')
self.lib_modules[module] = args
return all_found
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index c35022d..2ac91b1 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -305,7 +305,7 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
lib_ext = get_shared_library_suffix(environment, self.for_machine)
libdir = self.get_config_value(['--libdir'], 'link_args')[0]
# Sort for reproducibility
- matches = sorted(glob.iglob(os.path.join(libdir, 'libLLVM*{}'.format(lib_ext))))
+ matches = sorted(glob.iglob(os.path.join(libdir, f'libLLVM*{lib_ext}')))
if not matches:
if self.required:
raise
@@ -314,7 +314,7 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
self.link_args = self.get_config_value(['--ldflags'], 'link_args')
libname = os.path.basename(matches[0]).rstrip(lib_ext).lstrip('lib')
- self.link_args.append('-l{}'.format(libname))
+ self.link_args.append(f'-l{libname}')
return
elif self.static and mode == 'shared':
# If, however LLVM_BUILD_SHARED_LIBS is true # (*cough* gentoo *cough*)
@@ -353,12 +353,12 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
# called libLLVM-<ver>.(so|dylib|dll)
libdir = self.get_config_value(['--libdir'], 'link_args')[0]
- expected_name = 'libLLVM-{}'.format(self.version)
- re_name = re.compile(r'{}.(so|dll|dylib)$'.format(expected_name))
+ expected_name = f'libLLVM-{self.version}'
+ re_name = re.compile(fr'{expected_name}.(so|dll|dylib)$')
for file_ in os.listdir(libdir):
if re_name.match(file_):
- self.link_args = ['-L{}'.format(libdir),
+ self.link_args = [f'-L{libdir}',
'-l{}'.format(os.path.splitext(file_.lstrip('lib'))[0])]
break
else:
@@ -379,7 +379,7 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
self.is_found = False
if self.required:
raise DependencyException(
- 'Could not find required LLVM Component: {}'.format(mod))
+ f'Could not find required LLVM Component: {mod}')
status = '(missing)'
else:
status = '(missing but optional)'
@@ -431,10 +431,10 @@ class LLVMDependencyCMake(CMakeDependency):
def _map_module_list(self, modules: T.List[T.Tuple[str, bool]], components: T.List[T.Tuple[str, bool]]) -> T.List[T.Tuple[str, bool]]:
res = []
for mod, required in modules:
- cm_targets = self.traceparser.get_cmake_var('MESON_LLVM_TARGETS_{}'.format(mod))
+ cm_targets = self.traceparser.get_cmake_var(f'MESON_LLVM_TARGETS_{mod}')
if not cm_targets:
if required:
- raise self._gen_exception('LLVM module {} was not found'.format(mod))
+ raise self._gen_exception(f'LLVM module {mod} was not found')
else:
mlog.warning('Optional LLVM module', mlog.bold(mod), 'was not found')
continue
@@ -443,7 +443,7 @@ class LLVMDependencyCMake(CMakeDependency):
return res
def _original_module_name(self, module: str) -> str:
- orig_name = self.traceparser.get_cmake_var('MESON_TARGET_TO_LLVM_{}'.format(module))
+ orig_name = self.traceparser.get_cmake_var(f'MESON_TARGET_TO_LLVM_{module}')
if orig_name:
return orig_name[0]
return module
@@ -493,7 +493,7 @@ class ZlibSystemDependency(ExternalDependency):
else:
return
else:
- mlog.debug('Unsupported OS {}'.format(m.system))
+ mlog.debug(f'Unsupported OS {m.system}')
return
v, _ = self.clib_compiler.get_define('ZLIB_VERSION', '#include <zlib.h>', self.env, [], [self])
diff --git a/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py
index 7c35a02..59c7382 100644
--- a/mesonbuild/dependencies/hdf5.py
+++ b/mesonbuild/dependencies/hdf5.py
@@ -41,7 +41,7 @@ class HDF5PkgConfigDependency(PkgConfigDependency):
def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:
language = language or 'c'
if language not in {'c', 'cpp', 'fortran'}:
- raise DependencyException('Language {} is not supported with HDF5.'.format(language))
+ raise DependencyException(f'Language {language} is not supported with HDF5.')
super().__init__(name, environment, kwargs, language)
if not self.is_found:
@@ -92,7 +92,7 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None:
language = language or 'c'
if language not in {'c', 'cpp', 'fortran'}:
- raise DependencyException('Language {} is not supported with HDF5.'.format(language))
+ raise DependencyException(f'Language {language} is not supported with HDF5.')
if language == 'c':
cenv = 'CC'
@@ -117,12 +117,12 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
# linkers.
compiler = environment.coredata.compilers[for_machine][language]
try:
- os.environ['HDF5_{}'.format(cenv)] = join_args(compiler.get_exelist())
- os.environ['HDF5_{}LINKER'.format(cenv)] = join_args(compiler.get_linker_exelist())
+ os.environ[f'HDF5_{cenv}'] = join_args(compiler.get_exelist())
+ os.environ[f'HDF5_{cenv}LINKER'] = join_args(compiler.get_linker_exelist())
super().__init__(name, environment, nkwargs, language)
finally:
- del os.environ['HDF5_{}'.format(cenv)]
- del os.environ['HDF5_{}LINKER'.format(cenv)]
+ del os.environ[f'HDF5_{cenv}']
+ del os.environ[f'HDF5_{cenv}LINKER']
if not self.is_found:
return
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index b0b8f4a..46f2337 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -40,7 +40,7 @@ def netcdf_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyType']:
language = kwargs.get('language', 'c')
if language not in ('c', 'cpp', 'fortran'):
- raise DependencyException('Language {} is not supported with NetCDF.'.format(language))
+ raise DependencyException(f'Language {language} is not supported with NetCDF.')
candidates = [] # type: T.List['DependencyType']
@@ -187,7 +187,7 @@ class Python3DependencySystem(ExternalDependency):
return '32'
elif pyplat in ('win64', 'win-amd64'):
return '64'
- mlog.log('Unknown Windows Python platform {!r}'.format(pyplat))
+ mlog.log(f'Unknown Windows Python platform {pyplat!r}')
return None
def get_windows_link_args(self):
@@ -195,13 +195,13 @@ class Python3DependencySystem(ExternalDependency):
if pyplat.startswith('win'):
vernum = sysconfig.get_config_var('py_version_nodot')
if self.static:
- libpath = Path('libs') / 'libpython{}.a'.format(vernum)
+ libpath = Path('libs') / f'libpython{vernum}.a'
else:
comp = self.get_compiler()
if comp.id == "gcc":
- libpath = 'python{}.dll'.format(vernum)
+ libpath = f'python{vernum}.dll'
else:
- libpath = Path('libs') / 'python{}.lib'.format(vernum)
+ libpath = Path('libs') / f'python{vernum}.lib'
lib = Path(sysconfig.get_config_var('base')) / libpath
elif pyplat == 'mingw':
if self.static:
@@ -230,7 +230,7 @@ class Python3DependencySystem(ExternalDependency):
arch = '64'
else:
# We can't cross-compile Python 3 dependencies on Windows yet
- mlog.log('Unknown architecture {!r} for'.format(arch),
+ mlog.log(f'Unknown architecture {arch!r} for',
mlog.bold(self.name))
self.is_found = False
return
@@ -452,12 +452,12 @@ class CursesSystemDependency(ExternalDependency):
# implementations. The one in illumos/OpenIndiana
# doesn't seem to have a version defined in the header.
if lib.startswith('ncurses'):
- v, _ = self.clib_compiler.get_define('NCURSES_VERSION', '#include <{}>'.format(header), env, [], [self])
+ v, _ = self.clib_compiler.get_define('NCURSES_VERSION', f'#include <{header}>', env, [], [self])
self.version = v.strip('"')
if lib.startswith('pdcurses'):
- v_major, _ = self.clib_compiler.get_define('PDC_VER_MAJOR', '#include <{}>'.format(header), env, [], [self])
- v_minor, _ = self.clib_compiler.get_define('PDC_VER_MINOR', '#include <{}>'.format(header), env, [], [self])
- self.version = '{}.{}'.format(v_major, v_minor)
+ v_major, _ = self.clib_compiler.get_define('PDC_VER_MAJOR', f'#include <{header}>', env, [], [self])
+ v_minor, _ = self.clib_compiler.get_define('PDC_VER_MINOR', f'#include <{header}>', env, [], [self])
+ self.version = f'{v_major}.{v_minor}'
# Check the version if possible, emit a wraning if we can't
req = kwargs.get('version')
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index d897d76..e323073 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -227,9 +227,9 @@ class QtBaseDependency(ExternalDependency):
# It is important that this list does not change order as the order of
# the returned ExternalPrograms will change as well
bins = ['moc', 'uic', 'rcc', 'lrelease']
- found = {b: NonExistingExternalProgram(name='{}-{}'.format(b, self.name))
+ found = {b: NonExistingExternalProgram(name=f'{b}-{self.name}')
for b in bins}
- wanted = '== {}'.format(self.version)
+ wanted = f'== {self.version}'
def gen_bins():
for b in bins:
@@ -237,7 +237,7 @@ class QtBaseDependency(ExternalDependency):
yield os.path.join(self.bindir, b), b
# prefer the <tool>-qt<version> of the tool to the plain one, as we
# don't know what the unsuffixed one points to without calling it.
- yield '{}-{}'.format(b, self.name), b
+ yield f'{b}-{self.name}', b
yield b, b
for b, name in gen_bins():
@@ -510,7 +510,7 @@ class QtBaseDependency(ExternalDependency):
return 'modules: ' + module_str
def log_info(self):
- return '{}'.format(self.from_text)
+ return f'{self.from_text}'
def log_tried(self):
return self.from_text