aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-03-02 22:17:38 -0500
committerXavier Claessens <xclaesse@gmail.com>2021-03-04 11:33:22 -0500
commitba9bfd2bd84985d8915f79d2415bffe68e9deada (patch)
treeafd108657534f73fec6610c327bbaa721fe14409 /mesonbuild/modules/python.py
parent1e69908be5fb738cd787f0e4825da395e9b356b2 (diff)
downloadmeson-ba9bfd2bd84985d8915f79d2415bffe68e9deada.zip
meson-ba9bfd2bd84985d8915f79d2415bffe68e9deada.tar.gz
meson-ba9bfd2bd84985d8915f79d2415bffe68e9deada.tar.bz2
Simplify module API
- ModuleState is now a real class that will have methods in the future for actions modules needs, instead of using interpreter internal API. - New ModuleObject base class, similar to InterpreterObject, that should be used by all objects returned by modules. Its methods gets the ModuleState passed as first argument. It has a `methods` dictionary to define what is public API that can be called from build definition. - Method return value is not required to be a ModuleReturnValue any more, it can be any type that interpreter can holderify, including ModuleObject. - Legacy module API is maintained until we port all modules. In the future modules should be updated: - Use methods dict. - Remove snippets. - Custom objects returned by modules should all be subclass of ModuleObject to get the state iface in their methods. - Modules should never call into interpreter directly and instead state object should have wrapper API. - Stop using ModuleReturnValue in methods that just return simple objects like strings. Possibly remove ModuleReturnValue completely since all objects that needs to be processed by interpreter (e.g. CustomTarget) should be created through ModuleState API.
Diffstat (limited to 'mesonbuild/modules/python.py')
-rw-r--r--mesonbuild/modules/python.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 564d181..cfe2244 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -21,7 +21,6 @@ from pathlib import Path
from .. import mesonlib
from ..mesonlib import MachineChoice, MesonException
from . import ExtensionModule
-from mesonbuild.modules import ModuleReturnValue
from ..interpreterbase import (
noPosargs, noKwargs, permittedKwargs,
InvalidArguments,
@@ -399,12 +398,12 @@ class PythonInstallation(ExternalProgramHolder):
else:
res = os.path.join(self.platlib_install_path, subdir)
- return self.interpreter.module_method_callback(ModuleReturnValue(res, []))
+ return res
@noPosargs
@noKwargs
def language_version_method(self, args, kwargs):
- return self.interpreter.module_method_callback(ModuleReturnValue(self.version, []))
+ return self.version
@noKwargs
def has_path_method(self, args, kwargs):
@@ -414,7 +413,7 @@ class PythonInstallation(ExternalProgramHolder):
if not isinstance(path_name, str):
raise InvalidArguments('has_path argument must be a string.')
- return self.interpreter.module_method_callback(ModuleReturnValue(path_name in self.paths, []))
+ return path_name in self.paths
@noKwargs
def get_path_method(self, args, kwargs):
@@ -432,7 +431,7 @@ class PythonInstallation(ExternalProgramHolder):
else:
raise InvalidArguments('{} is not a valid path name'.format(path_name))
- return self.interpreter.module_method_callback(ModuleReturnValue(path, []))
+ return path
@noKwargs
def has_variable_method(self, args, kwargs):
@@ -442,7 +441,7 @@ class PythonInstallation(ExternalProgramHolder):
if not isinstance(var_name, str):
raise InvalidArguments('has_variable argument must be a string.')
- return self.interpreter.module_method_callback(ModuleReturnValue(var_name in self.variables, []))
+ return var_name in self.variables
@noKwargs
def get_variable_method(self, args, kwargs):
@@ -460,7 +459,7 @@ class PythonInstallation(ExternalProgramHolder):
else:
raise InvalidArguments('{} is not a valid variable name'.format(var_name))
- return self.interpreter.module_method_callback(ModuleReturnValue(var, []))
+ return var
@noPosargs
@noKwargs