diff options
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 22 | ||||
-rw-r--r-- | mesonbuild/dependencies/boost.py | 22 | ||||
-rw-r--r-- | mesonbuild/dependencies/hdf5.py | 10 | ||||
-rw-r--r-- | mesonbuild/dependencies/mpi.py | 5 |
4 files changed, 34 insertions, 25 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 5d2a000..69b81d5 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -114,11 +114,11 @@ class Dependency: def __init__(self, type_name, kwargs): self.name = "null" - self.version = None + self.version = None # type: T.Optional[str] self.language = None # None means C-like self.is_found = False self.type_name = type_name - self.compile_args = [] + self.compile_args = [] # type: T.List[str] self.link_args = [] # Raw -L and -l arguments without manual library searching # If None, self.link_args will be used @@ -132,7 +132,7 @@ class Dependency: s = '<{0} {1}: {2}>' return s.format(self.__class__.__name__, self.name, self.is_found) - def get_compile_args(self): + def get_compile_args(self) -> T.List[str]: if self.include_type == 'system': converted = [] for i in self.compile_args: @@ -156,7 +156,7 @@ class Dependency: return self.raw_link_args return self.link_args - def found(self): + def found(self) -> bool: return self.is_found def get_sources(self): @@ -171,7 +171,7 @@ class Dependency: def get_name(self): return self.name - def get_version(self): + def get_version(self) -> str: if self.version: return self.version else: @@ -183,7 +183,7 @@ class Dependency: def get_exe_args(self, compiler): return [] - def get_pkgconfig_variable(self, variable_name, kwargs): + 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)) def get_configtool_variable(self, variable_name): @@ -261,7 +261,7 @@ class InternalDependency(Dependency): setattr(result, k, copy.deepcopy(v, memo)) return result - def get_pkgconfig_variable(self, variable_name, kwargs): + def get_pkgconfig_variable(self, variable_name: str, kwargs: T.Dict[str, T.Any]) -> str: raise DependencyException('Method "get_pkgconfig_variable()" is ' 'invalid for an internal dependency') @@ -504,7 +504,7 @@ class ConfigToolDependency(ExternalDependency): return self.config is not None - def get_config_value(self, args, stage): + def get_config_value(self, args: T.List[str], stage: str) -> T.List[str]: p, out, err = Popen_safe(self.config + args) if p.returncode != 0: if self.required: @@ -877,7 +877,7 @@ class PkgConfigDependency(ExternalDependency): (self.name, out_raw)) self.link_args, self.raw_link_args = self._search_libs(out, out_raw) - def get_pkgconfig_variable(self, variable_name, kwargs): + def get_pkgconfig_variable(self, variable_name: str, kwargs: T.Dict[str, T.Any]) -> str: options = ['--variable=' + variable_name, self.name] if 'define_variable' in kwargs: @@ -2037,7 +2037,7 @@ class ExternalProgram: def found(self) -> bool: return self.command[0] is not None - def get_command(self): + def get_command(self) -> T.List[str]: return self.command[:] def get_path(self): @@ -2550,7 +2550,7 @@ def factory_methods(methods: T.Set[DependencyMethods]) -> T.Callable[['FactoryTy This helps to make factory functions self documenting >>> @factory_methods([DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE]) - >>> def factory(env: Environment, for_machine: MachineChoice, kwargs: T.Dict[str, T.Any], methods: T.Set[DependencyMethods]) -> T.List[DependencyType]: + >>> def factory(env: Environment, for_machine: MachineChoice, kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List[T.Callable[[], 'Dependency']]: >>> pass """ diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py index 3ad534e..370fa72 100644 --- a/mesonbuild/dependencies/boost.py +++ b/mesonbuild/dependencies/boost.py @@ -95,7 +95,7 @@ class BoostIncludeDir(): def __repr__(self) -> str: return '<BoostIncludeDir: {} -- {}>'.format(self.version, self.path) - def __lt__(self, other: T.Any) -> bool: + def __lt__(self, other: object) -> bool: if isinstance(other, BoostIncludeDir): return (self.version_int, self.path) < (other.version_int, other.path) return NotImplemented @@ -187,7 +187,7 @@ class BoostLibraryFile(): def __repr__(self) -> str: return '<LIB: {} {:<32} {}>'.format(self.abitag, self.mod_name, self.path) - def __lt__(self, other: T.Any) -> bool: + def __lt__(self, other: object) -> bool: if isinstance(other, BoostLibraryFile): return ( self.mod_name, self.static, self.version_lib, self.arch, @@ -204,7 +204,7 @@ class BoostLibraryFile(): ) return NotImplemented - def __eq__(self, other: T.Any) -> bool: + def __eq__(self, other: object) -> bool: if isinstance(other, BoostLibraryFile): return self.name == other.name return NotImplemented @@ -339,12 +339,14 @@ class BoostLibraryFile(): return [self.path.as_posix()] class BoostDependency(ExternalDependency): - def __init__(self, environment: Environment, kwargs): + def __init__(self, environment: Environment, kwargs: T.Dict[str, T.Any]) -> None: super().__init__('boost', environment, kwargs, language='cpp') - self.debug = environment.coredata.get_builtin_option('buildtype').startswith('debug') + buildtype = environment.coredata.get_builtin_option('buildtype') + assert isinstance(buildtype, str) + self.debug = buildtype.startswith('debug') self.multithreading = kwargs.get('threading', 'multi') == 'multi' - self.boost_root = None + self.boost_root = None # type: T.Optional[Path] self.explicit_static = 'static' in kwargs # Extract and validate modules @@ -385,7 +387,7 @@ class BoostDependency(ExternalDependency): # Finally, look for paths from .pc files and from searching the filesystem self.detect_roots() - def check_and_set_roots(self, roots) -> None: + def check_and_set_roots(self, roots: T.List[Path]) -> None: roots = list(mesonlib.OrderedSet(roots)) for j in roots: # 1. Look for the boost headers (boost/version.hpp) @@ -403,7 +405,7 @@ class BoostDependency(ExternalDependency): self.boost_root = j break - def detect_boost_machine_file(self, props) -> None: + def detect_boost_machine_file(self, props: T.Dict[str, str]) -> None: incdir = props.get('boost_includedir') libdir = props.get('boost_librarydir') @@ -434,7 +436,7 @@ class BoostDependency(ExternalDependency): self.check_and_set_roots(paths) - def detect_boost_env(self): + def detect_boost_env(self) -> None: boost_includedir = get_env_var(self.for_machine, self.env.is_cross_build, 'BOOST_INCLUDEDIR') boost_librarydir = get_env_var(self.for_machine, self.env.is_cross_build, 'BOOST_LIBRARYDIR') @@ -658,7 +660,7 @@ class BoostDependency(ExternalDependency): libs += [BoostLibraryFile(i)] return [x for x in libs if x.is_boost()] # Filter out no boost libraries - def detect_split_root(self, inc_dir, lib_dir) -> None: + def detect_split_root(self, inc_dir: Path, lib_dir: Path) -> None: boost_inc_dir = None for j in [inc_dir / 'version.hpp', inc_dir / 'boost' / 'version.hpp']: if j.is_file(): diff --git a/mesonbuild/dependencies/hdf5.py b/mesonbuild/dependencies/hdf5.py index 6a9bf2d..6280010 100644 --- a/mesonbuild/dependencies/hdf5.py +++ b/mesonbuild/dependencies/hdf5.py @@ -22,10 +22,14 @@ from .. import mlog from ..mesonlib import split_args, listify from .base import (DependencyException, DependencyMethods, ExternalDependency, ExternalProgram, PkgConfigDependency) +import typing as T + +if T.TYPE_CHECKING: + from ..environment import Environment class HDF5Dependency(ExternalDependency): - def __init__(self, environment, kwargs): + def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: language = kwargs.get('language', 'c') super().__init__('hdf5', environment, kwargs, language=language) kwargs['required'] = False @@ -109,7 +113,7 @@ class HDF5Dependency(ExternalDependency): cmd = prog.get_command() + [shlib_arg, '-show'] p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, timeout=15) if p.returncode != 0: - mlog.debug('Command', mlog.bold(cmd), 'failed to run:') + mlog.debug('Command', mlog.bold(str(cmd)), 'failed to run:') mlog.debug(mlog.bold('Standard output\n'), p.stdout) mlog.debug(mlog.bold('Standard error\n'), p.stderr) return @@ -127,5 +131,5 @@ class HDF5Dependency(ExternalDependency): return @staticmethod - def get_methods(): + def get_methods() -> T.List[DependencyMethods]: return [DependencyMethods.AUTO, DependencyMethods.PKGCONFIG] diff --git a/mesonbuild/dependencies/mpi.py b/mesonbuild/dependencies/mpi.py index f25a990..2e1e764 100644 --- a/mesonbuild/dependencies/mpi.py +++ b/mesonbuild/dependencies/mpi.py @@ -24,6 +24,7 @@ from ..environment import detect_cpu_family if T.TYPE_CHECKING: from .base import Dependency from ..compilers import Compiler + from ..compilers.compiler import CompilerType from ..environment import Environment, MachineChoice @@ -36,7 +37,9 @@ def mpi_factory(env: 'Environment', for_machine: 'MachineChoice', return [] candidates = [] # type: T.List[T.Callable[[], Dependency]] - compiler = detect_compiler('mpi', env, for_machine, language) + compiler = detect_compiler('mpi', env, for_machine, language) # type: T.Optional['CompilerType'] + if compiler is None: + return [] compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'} # Only OpenMPI has pkg-config, and it doesn't work with the intel compilers |