Exemple #1
0
    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, []))
Exemple #2
0
    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, [])
Exemple #3
0
 def language_version_method(self, args, kwargs):
     return self.interpreter.module_method_callback(
         ModuleReturnValue(self.version, []))
Exemple #4
0
 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(), [])
Exemple #5
0
 def find_python(self, state, args, kwargs):
     py3 = dependencies.ExternalProgram('python3',
                                        sys.executable,
                                        silent=True)
     return ModuleReturnValue(py3, [py3])
Exemple #6
0
 def found(self, node, args, kwargs):
     return ModuleReturnValue(True, [])
Exemple #7
0
 def language_version(self, node, args, kwargs):
     return ModuleReturnValue(self.version, [])
Exemple #8
0
 def language_version(self, state, args, kwargs):
     return ModuleReturnValue(sysconfig.get_python_version(), [])
Exemple #9
0
 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])
Exemple #10
0
 def find_python(self, state, args, kwargs):
     py3 = dependencies.ExternalProgram('python3', mesonlib.python_command, silent=True)
     return ModuleReturnValue(py3, [py3])
Exemple #11
0
 def config(self, state, args, kwargs):
     config_data = self._config(state)
     return ModuleReturnValue(config_data, [config_data])
Exemple #12
0
 def setup(self, state, args, kwargs):
     self.options.update(kwargs)
     return ModuleReturnValue(None, [])