diff options
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/__init__.py | 8 | ||||
-rw-r--r-- | mesonbuild/modules/cmake.py | 14 | ||||
-rw-r--r-- | mesonbuild/modules/fs.py | 4 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 34 | ||||
-rw-r--r-- | mesonbuild/modules/hotdoc.py | 6 | ||||
-rw-r--r-- | mesonbuild/modules/i18n.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/keyval.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 10 | ||||
-rw-r--r-- | mesonbuild/modules/python.py | 38 | ||||
-rw-r--r-- | mesonbuild/modules/python3.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/qt.py | 20 | ||||
-rw-r--r-- | mesonbuild/modules/sourceset.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/unstable_external_project.py | 18 | ||||
-rw-r--r-- | mesonbuild/modules/windows.py | 2 |
14 files changed, 81 insertions, 81 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 1cf7c1c..ddb5e3e 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -82,7 +82,7 @@ def get_include_args(include_dirs, prefix='-I'): dirs_str = [] for dirs in unholder(include_dirs): if isinstance(dirs, str): - dirs_str += ['%s%s' % (prefix, dirs)] + dirs_str += [f'{prefix}{dirs}'] continue # Should be build.IncludeDirs object. @@ -91,10 +91,10 @@ def get_include_args(include_dirs, prefix='-I'): expdir = os.path.join(basedir, d) srctreedir = os.path.join('@SOURCE_ROOT@', expdir) buildtreedir = os.path.join('@BUILD_ROOT@', expdir) - dirs_str += ['%s%s' % (prefix, buildtreedir), - '%s%s' % (prefix, srctreedir)] + dirs_str += [f'{prefix}{buildtreedir}', + f'{prefix}{srctreedir}'] for d in dirs.get_extra_build_dirs(): - dirs_str += ['%s%s' % (prefix, d)] + dirs_str += [f'{prefix}{d}'] return dirs_str diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index 18dc2f5..fd92ecf 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -92,7 +92,7 @@ class CMakeSubprojectHolder(InterpreterObject, ObjectHolder): tgt = args[0] res = self.held_object.cm_interpreter.target_info(tgt) if res is None: - raise InterpreterException('The CMake target {} does not exist\n'.format(tgt) + + raise InterpreterException(f'The CMake target {tgt} does not exist\n' + ' Use the following command in your meson.build to list all available targets:\n\n' + ' message(\'CMaket targets:\\n - \' + \'\\n - \'.join(<cmake_subproject>.target_list()))') @@ -235,7 +235,7 @@ class CmakeModule(ExtensionModule): cmakebin = dependencies.ExternalProgram('cmake', silent=False) p, stdout, stderr = mesonlib.Popen_safe(cmakebin.get_command() + ['--system-information', '-G', 'Ninja'])[0:3] if p.returncode != 0: - mlog.log('error retrieving cmake information: returnCode={} stdout={} stderr={}'.format(p.returncode, stdout, stderr)) + mlog.log(f'error retrieving cmake information: returnCode={p.returncode} stdout={stdout} stderr={stderr}') return False match = re.search('\nCMAKE_ROOT \\"([^"]+)"\n', stdout.strip()) @@ -273,11 +273,11 @@ class CmakeModule(ExtensionModule): if not isinstance(pkgroot, str): raise mesonlib.MesonException('Install_dir must be a string.') - template_file = os.path.join(self.cmake_root, 'Modules', 'BasicConfigVersion-{}.cmake.in'.format(compatibility)) + template_file = os.path.join(self.cmake_root, 'Modules', f'BasicConfigVersion-{compatibility}.cmake.in') if not os.path.exists(template_file): - raise mesonlib.MesonException('your cmake installation doesn\'t support the {} compatibility'.format(compatibility)) + raise mesonlib.MesonException(f'your cmake installation doesn\'t support the {compatibility} compatibility') - version_file = os.path.join(state.environment.scratch_dir, '{}ConfigVersion.cmake'.format(name)) + version_file = os.path.join(state.environment.scratch_dir, f'{name}ConfigVersion.cmake') conf = { 'CVF_VERSION': (version, ''), @@ -298,7 +298,7 @@ class CmakeModule(ExtensionModule): with open(infile) as fin: data = fin.readlines() except Exception as e: - raise mesonlib.MesonException('Could not read input file %s: %s' % (infile, str(e))) + raise mesonlib.MesonException('Could not read input file {}: {}'.format(infile, str(e))) result = [] regex = re.compile(r'(?:\\\\)+(?=\\?@)|\\@|@([-a-zA-Z0-9_]+)@') @@ -339,7 +339,7 @@ class CmakeModule(ExtensionModule): raise mesonlib.MesonException('"name" not specified.') name = kwargs['name'] - (ofile_path, ofile_fname) = os.path.split(os.path.join(state.subdir, '{}Config.cmake'.format(name))) + (ofile_path, ofile_fname) = os.path.split(os.path.join(state.subdir, f'{name}Config.cmake')) ofile_abs = os.path.join(state.environment.build_dir, ofile_path, ofile_fname) install_dir = kwargs.get('install_dir', os.path.join(state.environment.coredata.get_option(mesonlib.OptionKey('libdir')), 'cmake', name)) diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py index fd1e99b..9594460 100644 --- a/mesonbuild/modules/fs.py +++ b/mesonbuild/modules/fs.py @@ -113,7 +113,7 @@ class FSModule(ExtensionModule): def hash(self, state: 'ModuleState', args: T.Tuple[str, str], kwargs: T.Dict[str, T.Any]) -> ModuleReturnValue: file = self._resolve_dir(state, args[0]) if not file.is_file(): - raise MesonException('{} is not a file and therefore cannot be hashed'.format(file)) + raise MesonException(f'{file} is not a file and therefore cannot be hashed') try: h = hashlib.new(args[1]) except ValueError: @@ -127,7 +127,7 @@ class FSModule(ExtensionModule): def size(self, state: 'ModuleState', args: T.Tuple[str], kwargs: T.Dict[str, T.Any]) -> ModuleReturnValue: file = self._resolve_dir(state, args[0]) if not file.is_file(): - raise MesonException('{} is not a file and therefore cannot be sized'.format(file)) + raise MesonException(f'{file} is not a file and therefore cannot be sized') try: return ModuleReturnValue(file.stat().st_size, []) except ValueError: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index a0b0de8..f1df18a 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -200,7 +200,7 @@ class GnomeModule(ExtensionModule): 'to generate it at configure-time.' raise MesonException(m) else: - raise MesonException('Invalid file argument: {!r}'.format(ifile)) + raise MesonException(f'Invalid file argument: {ifile!r}') depend_files, depends, subdirs = self._get_gresource_dependencies( state, ifile, source_dirs, dependencies) @@ -424,7 +424,7 @@ class GnomeModule(ExtensionModule): lib_dir = os.path.dirname(lib) external_ldflags.update(["-L%s" % lib_dir]) if include_rpath: - external_ldflags.update(['-Wl,-rpath {}'.format(lib_dir)]) + external_ldflags.update([f'-Wl,-rpath {lib_dir}']) libname = os.path.basename(lib) if libname.startswith("lib"): libname = libname[3:] @@ -443,7 +443,7 @@ class GnomeModule(ExtensionModule): cflags.update(get_include_args(dep.get_include_dirs())) depends.append(dep) else: - mlog.log('dependency {!r} not handled to build gir files'.format(dep)) + mlog.log(f'dependency {dep!r} not handled to build gir files') continue if use_gir_args and self._gir_has_option('--extra-library'): @@ -528,14 +528,14 @@ class GnomeModule(ExtensionModule): includes = mesonlib.extract_as_list(kwargs, 'includes', pop = True) for inc in unholder(includes): if isinstance(inc, str): - ret += ['--include=%s' % (inc, )] + ret += [f'--include={inc}'] elif isinstance(inc, GirTarget): gir_inc_dirs += [ os.path.join(state.environment.get_build_dir(), inc.get_subdir()), ] ret += [ - "--include-uninstalled=%s" % (os.path.join(inc.get_subdir(), inc.get_basename()), ) + "--include-uninstalled={}".format(os.path.join(inc.get_subdir(), inc.get_basename())) ] depends += [inc] else: @@ -615,7 +615,7 @@ class GnomeModule(ExtensionModule): ret += ["-L@BUILD_ROOT@/{}".format(os.path.dirname(libpath))] libname = girtarget.get_basename() else: - libname = os.path.join("@BUILD_ROOT@/{}".format(libpath)) + libname = os.path.join(f"@BUILD_ROOT@/{libpath}") ret += ['--library', libname] # Needed for the following binutils bug: # https://github.com/mesonbuild/meson/issues/1911 @@ -682,7 +682,7 @@ class GnomeModule(ExtensionModule): gir_filelist_dir = state.backend.get_target_private_dir_abs(girtargets[0]) if not os.path.isdir(gir_filelist_dir): os.mkdir(gir_filelist_dir) - gir_filelist_filename = os.path.join(gir_filelist_dir, '%s_%s_gir_filelist' % (ns, nsversion)) + gir_filelist_filename = os.path.join(gir_filelist_dir, f'{ns}_{nsversion}_gir_filelist') with open(gir_filelist_filename, 'w', encoding='utf-8') as gir_filelist: for s in unholder(libsources): @@ -813,7 +813,7 @@ class GnomeModule(ExtensionModule): if not nsversion: raise MesonException('Missing "nsversion" keyword argument') libsources = mesonlib.extract_as_list(kwargs, 'sources', pop=True) - girfile = '%s-%s.gir' % (ns, nsversion) + girfile = f'{ns}-{nsversion}.gir' srcdir = os.path.join(state.environment.get_source_dir(), state.subdir) builddir = os.path.join(state.environment.get_build_dir(), state.subdir) depends = gir_dep.sources + girtargets @@ -875,7 +875,7 @@ class GnomeModule(ExtensionModule): scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs) - typelib_output = '%s-%s.typelib' % (ns, nsversion) + typelib_output = f'{ns}-{nsversion}.typelib' typelib_cmd = [gicompiler, scan_target, '--output', '@OUTPUT@'] typelib_cmd += get_include_args(gir_inc_dirs, prefix='--includedir=') @@ -1010,7 +1010,7 @@ class GnomeModule(ExtensionModule): mode = kwargs.get('mode', 'auto') VALID_MODES = ('xml', 'sgml', 'none', 'auto') if mode not in VALID_MODES: - raise MesonException('gtkdoc: Mode {} is not a valid mode: {}'.format(mode, VALID_MODES)) + raise MesonException(f'gtkdoc: Mode {mode} is not a valid mode: {VALID_MODES}') src_dirs = mesonlib.extract_as_list(kwargs, 'src_dir') header_dirs = [] @@ -1040,7 +1040,7 @@ class GnomeModule(ExtensionModule): program_name = 'gtkdoc-' + tool program = self.interpreter.find_program_impl(program_name) path = program.held_object.get_path() - args.append('--{}={}'.format(program_name, path)) + args.append(f'--{program_name}={path}') if namespace: args.append('--namespace=' + namespace) args += self._unpack_args('--htmlargs=', 'html_args', kwargs) @@ -1075,7 +1075,7 @@ class GnomeModule(ExtensionModule): s)) else: raise MesonException( - 'Invalid object type: {!r}'.format(s.__class__.__name__)) + f'Invalid object type: {s.__class__.__name__!r}') args += ['--content-files=' + '@@'.join(content_files)] args += self._unpack_args('--expand-content-files=', 'expand_content_files', kwargs, state) @@ -1363,7 +1363,7 @@ class GnomeModule(ExtensionModule): cmd += ['--' + arg.replace('_', '-'), value] elif arg not in known_custom_target_kwargs: raise MesonException( - 'Mkenums does not take a %s keyword argument.' % (arg, )) + f'Mkenums does not take a {arg} keyword argument.') cmd = [self.interpreter.find_program_impl(['glib-mkenums', 'mkenums'])] + cmd custom_kwargs = {} for arg in known_custom_target_kwargs: @@ -1429,7 +1429,7 @@ class GnomeModule(ExtensionModule): 'fprod', 'ftail', 'vhead', 'vtail', 'comments'] for arg in forbidden_kwargs: if arg in kwargs: - raise MesonException('mkenums_simple() does not take a %s keyword argument' % (arg, )) + raise MesonException(f'mkenums_simple() does not take a {arg} keyword argument') # kwargs to pass as-is from mkenums_simple() to mkenums() shared_kwargs = ['sources', 'install_header', 'install_dir', @@ -1581,8 +1581,8 @@ G_END_DECLS''' cmd += ['--' + arg.replace('_', '-')] elif arg not in known_custom_target_kwargs: raise MesonException( - 'Genmarshal does not take a %s keyword argument.' % ( - arg, )) + 'Genmarshal does not take a {} keyword argument.'.format( + arg)) install_header = kwargs.pop('install_header', False) install_dir = kwargs.pop('install_dir', None) @@ -1628,7 +1628,7 @@ G_END_DECLS''' for arg in arg_list: if not isinstance(arg, str): types = 'strings' + ' or InternalDependencys' if accept_vapi else '' - raise MesonException('All {} must be {}'.format(variable, types)) + raise MesonException(f'All {variable} must be {types}') ret.append(prefix + arg) return ret diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py index eda411c..51da31c 100644 --- a/mesonbuild/modules/hotdoc.py +++ b/mesonbuild/modules/hotdoc.py @@ -100,7 +100,7 @@ class HotdocTargetBuilder: # When an option expects a single value, the unambiguous way # to specify it is with = if isinstance(value, str): - self.cmd.extend(['%s=%s' % (option, value)]) + self.cmd.extend([f'{option}={value}']) else: self.cmd.extend([option, value]) @@ -113,7 +113,7 @@ class HotdocTargetBuilder: valid_types = (str, bool, mesonlib.File, build.IncludeDirs, build.CustomTarget, build.BuildTarget) if not isinstance(value, valid_types): - raise InvalidArguments('Argument "%s=%s" should be of type: %s.' % ( + raise InvalidArguments('Argument "{}={}" should be of type: {}.'.format( arg, value, [t.__name__ for t in valid_types])) def process_extra_args(self): @@ -403,7 +403,7 @@ class HotDocModule(ExtensionModule): from hotdoc.run_hotdoc import run # noqa: F401 self.hotdoc.run_hotdoc = run except Exception as e: - raise MesonException('hotdoc %s required but not found. (%s)' % ( + raise MesonException('hotdoc {} required but not found. ({})'.format( MIN_HOTDOC_VERSION, e)) @noKwargs diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 54faf4c..afa7287 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -83,7 +83,7 @@ class I18nModule(ExtensionModule): file_type = kwargs.pop('type', 'xml') VALID_TYPES = ('xml', 'desktop') if file_type not in VALID_TYPES: - raise MesonException('i18n: "{}" is not a valid type {}'.format(file_type, VALID_TYPES)) + raise MesonException(f'i18n: "{file_type}" is not a valid type {VALID_TYPES}') datadirs = self._get_data_dirs(state, mesonlib.stringlistify(kwargs.pop('data_dirs', []))) datadirs = '--datadirs=' + ':'.join(datadirs) if datadirs else None diff --git a/mesonbuild/modules/keyval.py b/mesonbuild/modules/keyval.py index 8e1a89f..8123a57 100644 --- a/mesonbuild/modules/keyval.py +++ b/mesonbuild/modules/keyval.py @@ -43,7 +43,7 @@ class KeyvalModule(ExtensionModule): continue result[name.strip()] = val.strip() except OSError as e: - raise mesonlib.MesonException('Failed to load {}: {}'.format(path_to_config, e)) + raise mesonlib.MesonException(f'Failed to load {path_to_config}: {e}') return result diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 57987ed..fd2c24a 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -356,10 +356,10 @@ class PkgConfigModule(ExtensionModule): ofile.write('Version: %s\n' % version) reqs_str = deps.format_reqs(deps.pub_reqs) if len(reqs_str) > 0: - ofile.write('Requires: {}\n'.format(reqs_str)) + ofile.write(f'Requires: {reqs_str}\n') reqs_str = deps.format_reqs(deps.priv_reqs) if len(reqs_str) > 0: - ofile.write('Requires.private: {}\n'.format(reqs_str)) + ofile.write(f'Requires.private: {reqs_str}\n') if len(conflicts) > 0: ofile.write('Conflicts: {}\n'.format(' '.join(conflicts))) @@ -380,7 +380,7 @@ class PkgConfigModule(ExtensionModule): continue if 'cs' in l.compilers: if isinstance(install_dir, str): - Lflag = '-r${prefix}/%s/%s' % (self._escape(self._make_relative(prefix, install_dir)), l.filename) + Lflag = '-r${{prefix}}/{}/{}'.format(self._escape(self._make_relative(prefix, install_dir)), l.filename) else: # install_dir is True Lflag = '-r${libdir}/%s' % l.filename else: @@ -473,7 +473,7 @@ class PkgConfigModule(ExtensionModule): default_subdirs = [] blocked_vars = ['libraries', 'libraries_private', 'require_private', 'extra_cflags', 'subdirs'] if len(set(kwargs) & set(blocked_vars)) > 0: - raise mesonlib.MesonException('Cannot combine dataonly with any of {}'.format(blocked_vars)) + raise mesonlib.MesonException(f'Cannot combine dataonly with any of {blocked_vars}') subdirs = mesonlib.stringlistify(kwargs.get('subdirs', default_subdirs)) version = kwargs.get('version', default_version) @@ -520,7 +520,7 @@ class PkgConfigModule(ExtensionModule): variables = [] for name, value in vardict.items(): if name in reserved: - raise mesonlib.MesonException('Variable "{}" is reserved'.format(name)) + raise mesonlib.MesonException(f'Variable "{name}" is reserved') variables.append((name, value)) return variables diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index d05c72a..122f977 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -63,10 +63,10 @@ class PythonDependency(ExternalDependency): pkg_version = self.variables.get('LDVERSION') or self.version pkg_libdir = self.variables.get('LIBPC') pkg_embed = '-embed' if self.embed and mesonlib.version_compare(self.version, '>=3.8') else '' - pkg_name = 'python-{}{}'.format(pkg_version, pkg_embed) + pkg_name = f'python-{pkg_version}{pkg_embed}' # If python-X.Y.pc exists in LIBPC, we will try to use it - if pkg_libdir is not None and Path(os.path.join(pkg_libdir, '{}.pc'.format(pkg_name))).is_file(): + if pkg_libdir is not None and Path(os.path.join(pkg_libdir, f'{pkg_name}.pc')).is_file(): old_pkg_libdir = os.environ.get('PKG_CONFIG_LIBDIR') old_pkg_path = os.environ.get('PKG_CONFIG_PATH') @@ -77,10 +77,10 @@ class PythonDependency(ExternalDependency): try: self.pkgdep = PkgConfigDependency(pkg_name, environment, kwargs) - mlog.debug('Found "{}" via pkgconfig lookup in LIBPC ({})'.format(pkg_name, pkg_libdir)) + mlog.debug(f'Found "{pkg_name}" via pkgconfig lookup in LIBPC ({pkg_libdir})') py_lookup_method = 'pkgconfig' except MesonException as e: - mlog.debug('"{}" could not be found in LIBPC ({})'.format(pkg_name, pkg_libdir)) + mlog.debug(f'"{pkg_name}" could not be found in LIBPC ({pkg_libdir})') mlog.debug(e) if old_pkg_path is not None: @@ -91,16 +91,16 @@ class PythonDependency(ExternalDependency): else: os.environ.pop('PKG_CONFIG_LIBDIR', None) else: - mlog.debug('"{}" could not be found in LIBPC ({}), this is likely due to a relocated python installation'.format(pkg_name, pkg_libdir)) + mlog.debug(f'"{pkg_name}" could not be found in LIBPC ({pkg_libdir}), this is likely due to a relocated python installation') # If lookup via LIBPC failed, try to use fallback PKG_CONFIG_LIBDIR/PKG_CONFIG_PATH mechanisms if self.pkgdep is None or not self.pkgdep.found(): try: self.pkgdep = PkgConfigDependency(pkg_name, environment, kwargs) - mlog.debug('Found "{}" via fallback pkgconfig lookup in PKG_CONFIG_LIBDIR/PKG_CONFIG_PATH'.format(pkg_name)) + mlog.debug(f'Found "{pkg_name}" via fallback pkgconfig lookup in PKG_CONFIG_LIBDIR/PKG_CONFIG_PATH') py_lookup_method = 'pkgconfig-fallback' except MesonException as e: - mlog.debug('"{}" could not be found via fallback pkgconfig lookup in PKG_CONFIG_LIBDIR/PKG_CONFIG_PATH'.format(pkg_name)) + mlog.debug(f'"{pkg_name}" could not be found via fallback pkgconfig lookup in PKG_CONFIG_LIBDIR/PKG_CONFIG_PATH') mlog.debug(e) if self.pkgdep and self.pkgdep.found(): @@ -118,11 +118,11 @@ class PythonDependency(ExternalDependency): else: self._find_libpy(python_holder, environment) if self.is_found: - mlog.debug('Found "python-{}" via SYSCONFIG module'.format(self.version)) + mlog.debug(f'Found "python-{self.version}" via SYSCONFIG module') py_lookup_method = 'sysconfig' if self.is_found: - mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES ({})'.format(py_lookup_method))) + mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green(f'YES ({py_lookup_method})')) else: mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO')) @@ -135,7 +135,7 @@ class PythonDependency(ExternalDependency): libdir = os.path.join(self.variables.get('base'), 'bin') libdirs = [libdir] else: - libname = 'python{}'.format(self.version) + libname = f'python{self.version}' if 'DEBUG_EXT' in self.variables: libname += self.variables['DEBUG_EXT'] if 'ABIFLAGS' in self.variables: @@ -170,20 +170,20 @@ class PythonDependency(ExternalDependency): return '32' elif self.platform in ('win64', 'win-amd64'): return '64' - mlog.log('Unknown Windows Python platform {!r}'.format(self.platform)) + mlog.log(f'Unknown Windows Python platform {self.platform!r}') return None def get_windows_link_args(self): if self.platform.startswith('win'): vernum = self.variables.get('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(self.variables.get('base')) / libpath elif self.platform == 'mingw': if self.static: @@ -212,7 +212,7 @@ class PythonDependency(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 @@ -429,7 +429,7 @@ class PythonInstallation(ExternalProgramHolder): if len(args) == 2: path = args[1] else: - raise InvalidArguments('{} is not a valid path name'.format(path_name)) + raise InvalidArguments(f'{path_name} is not a valid path name') return path @@ -457,7 +457,7 @@ class PythonInstallation(ExternalProgramHolder): if len(args) == 2: var = args[1] else: - raise InvalidArguments('{} is not a valid variable name'.format(var_name)) + raise InvalidArguments(f'{var_name} is not a valid variable name') return var @@ -544,7 +544,7 @@ class PythonModule(ExtensionModule): for mod in want_modules: p, out, err = mesonlib.Popen_safe( python.command + - ['-c', 'import {}'.format(mod)]) + ['-c', f'import {mod}']) if p.returncode != 0: missing_modules.append(mod) else: @@ -591,7 +591,7 @@ class PythonModule(ExtensionModule): else: res = ExternalProgramHolder(NonExistingExternalProgram(), state.subproject) if required: - raise mesonlib.MesonException('{} is not a valid python or it is missing setuptools'.format(python)) + raise mesonlib.MesonException(f'{python} is not a valid python or it is missing setuptools') return res diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py index 97bd5ec..8815966 100644 --- a/mesonbuild/modules/python3.py +++ b/mesonbuild/modules/python3.py @@ -66,7 +66,7 @@ class Python3Module(ExtensionModule): path_name = args[0] valid_names = sysconfig.get_path_names() if path_name not in valid_names: - raise mesonlib.MesonException('{} is not a valid path name {}.'.format(path_name, valid_names)) + raise mesonlib.MesonException(f'{path_name} is not a valid path name {valid_names}.') # Get a relative path without a prefix, e.g. lib/python3.6/site-packages path = sysconfig.get_path(path_name, vars={'base': '', 'platbase': '', 'installed_base': ''})[1:] diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 680ee72..32841ff 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -43,7 +43,7 @@ class QtBaseModule(ExtensionModule): if self.tools_detected: return self.tools_detected = True - mlog.log('Detecting Qt{version} tools'.format(version=self.qt_version)) + mlog.log(f'Detecting Qt{self.qt_version} tools') kwargs = {'required': required, 'modules': 'Core', 'method': method} qt = _QT_DEPS_LUT[self.qt_version](env, kwargs) if qt.found(): @@ -55,7 +55,7 @@ class QtBaseModule(ExtensionModule): mlog.warning('rcc dependencies will not work properly until you move to Qt >= 5.14:', mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460'), fatal=False) else: - suffix = '-qt{}'.format(self.qt_version) + suffix = f'-qt{self.qt_version}' self.moc = NonExistingExternalProgram(name='moc' + suffix) self.uic = NonExistingExternalProgram(name='uic' + suffix) self.rcc = NonExistingExternalProgram(name='rcc' + suffix) @@ -143,10 +143,10 @@ class QtBaseModule(ExtensionModule): err_msg = "{0} sources specified and couldn't find {1}, " \ "please check your qt{2} installation" if (moc_headers or moc_sources) and not self.moc.found(): - raise MesonException(err_msg.format('MOC', 'moc-qt{}'.format(self.qt_version), self.qt_version)) + raise MesonException(err_msg.format('MOC', f'moc-qt{self.qt_version}', self.qt_version)) if rcc_files: if not self.rcc.found(): - raise MesonException(err_msg.format('RCC', 'rcc-qt{}'.format(self.qt_version), self.qt_version)) + raise MesonException(err_msg.format('RCC', f'rcc-qt{self.qt_version}', self.qt_version)) # custom output name set? -> one output file, multiple otherwise if args: qrc_deps = [] @@ -178,12 +178,12 @@ class QtBaseModule(ExtensionModule): sources.append(res_target) if ui_files: if not self.uic.found(): - raise MesonException(err_msg.format('UIC', 'uic-qt{}'.format(self.qt_version), self.qt_version)) + raise MesonException(err_msg.format('UIC', f'uic-qt{self.qt_version}', self.qt_version)) arguments = uic_extra_arguments + ['-o', '@OUTPUT@', '@INPUT@'] ui_kwargs = {'output': 'ui_@BASENAME@.h', 'arguments': arguments} ui_gen = build.Generator([self.uic], ui_kwargs) - ui_output = ui_gen.process_files('Qt{} ui'.format(self.qt_version), ui_files, state) + ui_output = ui_gen.process_files(f'Qt{self.qt_version} ui', ui_files, state) sources.append(ui_output) inc = get_include_args(include_dirs=include_directories) compile_args = [] @@ -202,14 +202,14 @@ class QtBaseModule(ExtensionModule): moc_kwargs = {'output': 'moc_@BASENAME@.cpp', 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) - moc_output = moc_gen.process_files('Qt{} moc header'.format(self.qt_version), moc_headers, state) + moc_output = moc_gen.process_files(f'Qt{self.qt_version} moc header', moc_headers, state) sources.append(moc_output) if moc_sources: arguments = moc_extra_arguments + inc + compile_args + ['@INPUT@', '-o', '@OUTPUT@'] moc_kwargs = {'output': '@BASENAME@.moc', 'arguments': arguments} moc_gen = build.Generator([self.moc], moc_kwargs) - moc_output = moc_gen.process_files('Qt{} moc source'.format(self.qt_version), moc_sources, state) + moc_output = moc_gen.process_files(f'Qt{self.qt_version} moc source', moc_sources, state) sources.append(moc_output) return ModuleReturnValue(sources, sources) @@ -237,7 +237,7 @@ class QtBaseModule(ExtensionModule): if c.endswith('.qm'): ts_files.append(c.rstrip('.qm')+'.ts') else: - raise MesonException('qt.compile_translations: qresource can only contain qm files, found {}'.format(c)) + raise MesonException(f'qt.compile_translations: qresource can only contain qm files, found {c}') results = self.preprocess(state, [], {'qresources': qresource, 'rcc_extra_arguments': kwargs.get('rcc_extra_arguments', [])}) self._detect_tools(state.environment, kwargs.get('method', 'auto')) translations = [] @@ -258,7 +258,7 @@ class QtBaseModule(ExtensionModule): 'command': cmd} if install_dir is not None: lrelease_kwargs['install_dir'] = install_dir - lrelease_target = build.CustomTarget('qt{}-compile-{}'.format(self.qt_version, ts), outdir, state.subproject, lrelease_kwargs) + lrelease_target = build.CustomTarget(f'qt{self.qt_version}-compile-{ts}', outdir, state.subproject, lrelease_kwargs) translations.append(lrelease_target) if qresource: return ModuleReturnValue(results.return_value[0], [results.new_objects, translations]) diff --git a/mesonbuild/modules/sourceset.py b/mesonbuild/modules/sourceset.py index e49a548..15257e7 100644 --- a/mesonbuild/modules/sourceset.py +++ b/mesonbuild/modules/sourceset.py @@ -150,7 +150,7 @@ class SourceSetHolder(MutableInterpreterObject, ObjectHolder): if isinstance(config_data, dict): def _get_from_config_data(key): if strict and key not in config_data: - raise InterpreterException('Entry {} not in configuration dictionary.'.format(key)) + raise InterpreterException(f'Entry {key} not in configuration dictionary.') return config_data.get(key, False) else: config_cache = dict() diff --git a/mesonbuild/modules/unstable_external_project.py b/mesonbuild/modules/unstable_external_project.py index cb1ea85..8153908 100644 --- a/mesonbuild/modules/unstable_external_project.py +++ b/mesonbuild/modules/unstable_external_project.py @@ -140,7 +140,7 @@ class ExternalProject(InterpreterObject): # Ensure the user at least try to pass basic info to the build system, # like the prefix, libdir, etc. for key, default, val in variables: - key_format = '@{}@'.format(key) + key_format = f'@{key}@' for option in self.configure_options: if key_format in option: break @@ -160,13 +160,13 @@ class ExternalProject(InterpreterObject): if missing: var_list = ", ".join(map(repr, sorted(missing))) raise EnvironmentException( - "Variables {} in configure options are missing.".format(var_list)) + f"Variables {var_list} in configure options are missing.") return out def _run(self, step: str, command: T.List[str]): - mlog.log('External project {}:'.format(self.name), mlog.bold(step)) + mlog.log(f'External project {self.name}:', mlog.bold(step)) m = 'Running command ' + str(command) + ' in directory ' + str(self.build_dir) + '\n' - log_filename = Path(mlog.log_dir, '{}-{}.log'.format(self.name, step)) + log_filename = Path(mlog.log_dir, f'{self.name}-{step}.log') output = None if not self.verbose: output = open(log_filename, 'w') @@ -178,7 +178,7 @@ class ExternalProject(InterpreterObject): stderr=subprocess.STDOUT, stdout=output) if p.returncode != 0: - m = '{} step returned error code {}.'.format(step, p.returncode) + m = f'{step} step returned error code {p.returncode}.' if not self.verbose: m += '\nSee logs: ' + str(log_filename) raise MesonException(m) @@ -196,8 +196,8 @@ class ExternalProject(InterpreterObject): if self.verbose: cmd.append('--verbose') - target_kwargs = {'output': '{}.stamp'.format(self.name), - 'depfile': '{}.d'.format(self.name), + target_kwargs = {'output': f'{self.name}.stamp', + 'depfile': f'{self.name}.d', 'command': cmd + ['@OUTPUT@', '@DEPFILE@'], 'console': True, } @@ -237,8 +237,8 @@ class ExternalProject(InterpreterObject): version = self.project_version['version'] incdir = [] - compile_args = ['-I{}'.format(abs_includedir)] - link_args = ['-L{}'.format(abs_libdir), '-l{}'.format(libname)] + compile_args = [f'-I{abs_includedir}'] + link_args = [f'-L{abs_libdir}', f'-l{libname}'] libs = [] libs_whole = [] sources = self.target diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index b8715f2..54bd265 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -133,7 +133,7 @@ class WindowsModule(ExtensionModule): name_formatted = 'windows_compile_resources_' + src.get_filename() name = src.get_id() else: - raise MesonException('Unexpected source type {!r}. windows.compile_resources accepts only strings, files, custom targets, and lists thereof.'.format(src)) + raise MesonException(f'Unexpected source type {src!r}. windows.compile_resources accepts only strings, files, custom targets, and lists thereof.') # Path separators are not allowed in target names name = name.replace('/', '_').replace('\\', '_') |