typing: Rename some variables

pull/8859/head
Daniel Mensinger 4 years ago
parent a8cd45d3ab
commit 2263a84d07
  1. 2
      mesonbuild/dependencies/base.py
  2. 11
      mesonbuild/dependencies/coarrays.py
  3. 13
      mesonbuild/dependencies/detect.py
  4. 20
      mesonbuild/dependencies/factory.py
  5. 6
      mesonbuild/dependencies/hdf5.py
  6. 26
      mesonbuild/dependencies/misc.py
  7. 15
      mesonbuild/dependencies/mpi.py
  8. 6
      mesonbuild/dependencies/scalapack.py

@ -22,7 +22,7 @@ from enum import Enum
from .. import mlog
from ..compilers import clib_langs
from ..mesonlib import MachineChoice, MesonException, File
from ..mesonlib import MachineChoice, MesonException
from ..mesonlib import version_compare_many
from ..interpreterbase import FeatureDeprecated

@ -21,16 +21,17 @@ from .pkgconfig import PkgConfigDependency
from .factory import factory_methods
if T.TYPE_CHECKING:
from . base import Dependency
from . factory import TV_DepGenerators
from . factory import DependencyGenerator
from ..environment import Environment, MachineChoice
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE, DependencyMethods.SYSTEM})
def coarray_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
def coarray_factory(env: 'Environment',
for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
fcid = detect_compiler('coarray', env, for_machine, 'fortran').get_id()
candidates: 'TV_DepGenerators' = []
candidates: T.List['DependencyGenerator'] = []
if fcid == 'gcc':
# OpenCoarrays is the most commonly used method for Fortran Coarray with GCC

@ -25,10 +25,13 @@ import typing as T
if T.TYPE_CHECKING:
from ..environment import Environment
from .factory import DependencyFactory, TV_FactoryFunc, TV_DepGenerators
from .factory import DependencyFactory, WrappedFactoryFunc, DependencyGenerator
# These must be defined in this file to avoid cyclical references.
packages: T.Dict[str, T.Union[T.Type[ExternalDependency], 'DependencyFactory', 'TV_FactoryFunc']] = {}
packages: T.Dict[
str,
T.Union[T.Type[ExternalDependency], 'DependencyFactory', 'WrappedFactoryFunc']
] = {}
_packages_accept_language: T.Set[str] = set()
if T.TYPE_CHECKING:
@ -163,7 +166,7 @@ def find_external_dependency(name: str, env: 'Environment', kwargs: T.Dict[str,
def _build_external_dependency_list(name: str, env: 'Environment', for_machine: MachineChoice,
kwargs: T.Dict[str, T.Any]) -> 'TV_DepGenerators':
kwargs: T.Dict[str, T.Any]) -> T.List['DependencyGenerator']:
# First check if the method is valid
if 'method' in kwargs and kwargs['method'] not in [e.value for e in DependencyMethods]:
raise DependencyException('method {!r} is invalid'.format(kwargs['method']))
@ -181,11 +184,11 @@ def _build_external_dependency_list(name: str, env: 'Environment', for_machine:
func: T.Callable[[], 'ExternalDependency'] = lambda: entry1(env, kwargs) # type: ignore
dep = [func]
else:
entry2 = T.cast(T.Union['DependencyFactory', 'TV_FactoryFunc'], packages[lname])
entry2 = T.cast(T.Union['DependencyFactory', 'WrappedFactoryFunc'], packages[lname])
dep = entry2(env, for_machine, kwargs)
return dep
candidates: 'TV_DepGenerators' = []
candidates: T.List['DependencyGenerator'] = []
# If it's explicitly requested, use the dub detection method (only)
if 'dub' == kwargs.get('method', ''):

@ -26,24 +26,24 @@ if T.TYPE_CHECKING:
from ..environment import Environment
from .configtool import ConfigToolDependency
TV_DepGenerators = T.List[T.Callable[[], ExternalDependency]]
TV_WrappedFactoryFunc = T.Callable[
DependencyGenerator = T.Callable[[], ExternalDependency]
FactoryFunc = T.Callable[
[
'Environment',
MachineChoice,
T.Dict[str, T.Any],
T.List[DependencyMethods]
],
TV_DepGenerators
T.List[DependencyGenerator]
]
TV_FactoryFunc = T.Callable[
WrappedFactoryFunc = T.Callable[
[
'Environment',
MachineChoice,
T.Dict[str, T.Any]
],
TV_DepGenerators
T.List[DependencyGenerator]
]
class DependencyFactory:
@ -116,7 +116,7 @@ class DependencyFactory:
return True
def __call__(self, env: 'Environment', for_machine: MachineChoice,
kwargs: T.Dict[str, T.Any]) -> 'TV_DepGenerators':
kwargs: T.Dict[str, T.Any]) -> T.List['DependencyGenerator']:
"""Return a list of Dependencies with the arguments already attached."""
methods = process_method_kw(self.methods, kwargs)
nwargs = self.extra_kwargs.copy()
@ -126,19 +126,19 @@ class DependencyFactory:
if self._process_method(m, env, for_machine)]
def factory_methods(methods: T.Set[DependencyMethods]) -> T.Callable[['TV_WrappedFactoryFunc'], 'TV_FactoryFunc']:
def factory_methods(methods: T.Set[DependencyMethods]) -> T.Callable[['FactoryFunc'], 'WrappedFactoryFunc']:
"""Decorator for handling methods for dependency factory functions.
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.List[DependencyMethods]) -> 'TV_DepGenerators':
>>> def factory(env: Environment, for_machine: MachineChoice, kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
>>> pass
"""
def inner(func: 'TV_WrappedFactoryFunc') -> 'TV_FactoryFunc':
def inner(func: 'FactoryFunc') -> 'WrappedFactoryFunc':
@functools.wraps(func)
def wrapped(env: 'Environment', for_machine: MachineChoice, kwargs: T.Dict[str, T.Any]) -> 'TV_DepGenerators':
def wrapped(env: 'Environment', for_machine: MachineChoice, kwargs: T.Dict[str, T.Any]) -> T.List['DependencyGenerator']:
return func(env, for_machine, kwargs, process_method_kw(methods, kwargs))
return wrapped

@ -30,7 +30,7 @@ import typing as T
if T.TYPE_CHECKING:
from .base import Dependency
from .factory import TV_DepGenerators
from .factory import DependencyGenerator
from ..environment import Environment
from ..mesonlib import MachineChoice
@ -153,9 +153,9 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL})
def hdf5_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
language = kwargs.get('language')
candidates: 'TV_DepGenerators' = []
candidates: T.List['DependencyGenerator'] = []
if DependencyMethods.PKGCONFIG in methods:
# Use an ordered set so that these remain the first tried pkg-config files

@ -33,17 +33,19 @@ from .factory import DependencyFactory, factory_methods
if T.TYPE_CHECKING:
from ..environment import Environment, MachineChoice
from .factory import TV_DepGenerators
from .factory import DependencyGenerator
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE})
def netcdf_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
def netcdf_factory(env: 'Environment',
for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
language = kwargs.get('language', 'c')
if language not in ('c', 'cpp', 'fortran'):
raise DependencyException(f'Language {language} is not supported with NetCDF.')
candidates: 'TV_DepGenerators' = []
candidates: T.List['DependencyGenerator'] = []
if DependencyMethods.PKGCONFIG in methods:
if language == 'fortran':
@ -488,9 +490,11 @@ class CursesSystemDependency(ExternalDependency):
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM})
def curses_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
candidates: 'TV_DepGenerators' = []
def curses_factory(env: 'Environment',
for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
candidates: T.List['DependencyGenerator'] = []
if DependencyMethods.PKGCONFIG in methods:
pkgconfig_files = ['pdcurses', 'ncursesw', 'ncurses', 'curses']
@ -511,15 +515,17 @@ def curses_factory(env: 'Environment', for_machine: 'MachineChoice',
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM})
def shaderc_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
def shaderc_factory(env: 'Environment',
for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
"""Custom DependencyFactory for ShaderC.
ShaderC's odd you get three different libraries from the same build
thing are just easier to represent as a separate function than
twisting DependencyFactory even more.
"""
candidates: 'TV_DepGenerators' = []
candidates: T.List['DependencyGenerator'] = []
if DependencyMethods.PKGCONFIG in methods:
# ShaderC packages their shared and static libs together

@ -24,23 +24,22 @@ from .factory import factory_methods
from ..environment import detect_cpu_family
if T.TYPE_CHECKING:
from .base import Dependency
from .factory import TV_DepGenerators
from ..compilers import Compiler
from ..compilers.compiler import CompilerType
from .factory import DependencyGenerator
from ..environment import Environment, MachineChoice
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM})
def mpi_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
def mpi_factory(env: 'Environment',
for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
language = kwargs.get('language', 'c')
if language not in {'c', 'cpp', 'fortran'}:
# OpenMPI doesn't work without any other languages
return []
candidates: 'TV_DepGenerators' = []
compiler = detect_compiler('mpi', env, for_machine, language) # type: T.Optional['CompilerType']
candidates: T.List['DependencyGenerator'] = []
compiler = detect_compiler('mpi', env, for_machine, language)
if compiler is None:
return []
compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'}

@ -25,14 +25,14 @@ from .factory import factory_methods
if T.TYPE_CHECKING:
from ..environment import Environment, MachineChoice
from .factory import TV_DepGenerators
from .factory import DependencyGenerator
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE})
def scalapack_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> 'TV_DepGenerators':
candidates: 'TV_DepGenerators' = []
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
candidates: T.List['DependencyGenerator'] = []
if DependencyMethods.PKGCONFIG in methods:
mkl = 'mkl-static-lp64-iomp' if kwargs.get('static', False) else 'mkl-dynamic-lp64-iomp'

Loading…
Cancel
Save