def get_variable_method(self, args, kwargs): if len(args) not in (1, 2): raise InvalidArguments( 'get_variable must have one or two arguments.') var_name = args[0] if not isinstance(var_name, str): raise InvalidArguments('get_variable argument must be a string.') try: var = self.variables[var_name] except KeyError: if len(args) == 2: var = args[1] else: raise InvalidArguments( '{} is not a valid variable name'.format(var_name)) return self.interpreter.module_method_callback( ModuleReturnValue(var, []))
def sysconfig_path(self, state, args, kwargs): if len(args) != 1: raise mesonlib.MesonException( 'sysconfig_path() requires passing the name of path to get.') 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)) # 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:] return ModuleReturnValue(path, [])
def language_version_method(self, args, kwargs): return self.interpreter.module_method_callback( ModuleReturnValue(self.version, []))
def language_version(self, state, args, kwargs): if args or kwargs: raise mesonlib.MesonException( 'language_version() takes no arguments.') return ModuleReturnValue(sysconfig.get_python_version(), [])
def find_python(self, state, args, kwargs): py3 = dependencies.ExternalProgram('python3', sys.executable, silent=True) return ModuleReturnValue(py3, [py3])
def found(self, node, args, kwargs): return ModuleReturnValue(True, [])
def language_version(self, node, args, kwargs): return ModuleReturnValue(self.version, [])
def language_version(self, state, args, kwargs): return ModuleReturnValue(sysconfig.get_python_version(), [])
def find_python(self, state, args, kwargs): options = [state.environment.config_info.binaries.get('python3')] if not options[0]: # because this would be [None] options = ['python3', mesonlib.python_command] py3 = dependencies.ExternalProgram(*options, silent=True) return ModuleReturnValue(py3, [py3])
def find_python(self, state, args, kwargs): py3 = dependencies.ExternalProgram('python3', mesonlib.python_command, silent=True) return ModuleReturnValue(py3, [py3])
def config(self, state, args, kwargs): config_data = self._config(state) return ModuleReturnValue(config_data, [config_data])
def setup(self, state, args, kwargs): self.options.update(kwargs) return ModuleReturnValue(None, [])