From 3d04e5a150ea2a40cc9d531241fb6dbed21e8c7f Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 2 Apr 2019 15:26:35 -0700 Subject: modules/python: Remove spaces around keyword arguments just small style cleanups. --- mesonbuild/modules/python.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 34fe5a588..2dba00716 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -521,14 +521,14 @@ class PythonModule(ExtensionModule): pythonpath = self._get_win_pythonpath(name_or_path) if pythonpath is not None: name_or_path = pythonpath - python = ExternalProgram(name_or_path, silent = True) + python = ExternalProgram(name_or_path, silent=True) # Last ditch effort, python2 or python3 can be named python # on various platforms, let's not give up just yet, if an executable # named python is available and has a compatible version, let's use # it if not python.found() and name_or_path in ['python2', 'python3']: - python = ExternalProgram('python', silent = True) + python = ExternalProgram('python', silent=True) if not python.found(): if required: -- cgit v1.2.3 From 82346a2bd241fcf34e66f34ac653b580e8f395ef Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 2 Apr 2019 15:32:23 -0700 Subject: modules/python: Report program found in find_installation() Currently find_installation is silent, which is pretty annoying. Let's log it. --- mesonbuild/modules/python.py | 8 +++++--- test cases/python/1 basic/meson.build | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 2dba00716..693621b57 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -131,7 +131,7 @@ class PythonDependency(ExternalDependency): if self.is_found: mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES ({})'.format(py_lookup_method))) else: - mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO')) + mlog.log('Dependency', mlog.bold(self.name), 'found:', [mlog.red('NO')]) def _find_libpy(self, python_holder, environment): if python_holder.is_pypy: @@ -512,8 +512,7 @@ class PythonModule(ExtensionModule): raise InvalidArguments('find_installation argument must be a string.') if not name_or_path: - mlog.log("Using meson's python {}".format(mesonlib.python_command)) - python = ExternalProgram('python3', mesonlib.python_command, silent=True) + python = ExternalProgram('python3', mesonlib.python_command) else: python = ExternalProgram.from_entry('python3', name_or_path) @@ -530,6 +529,9 @@ class PythonModule(ExtensionModule): if not python.found() and name_or_path in ['python2', 'python3']: python = ExternalProgram('python', silent=True) + mlog.log('Program', python.name, 'found:', + *[mlog.green('YES'), '({})'.format(' '.join(python.command))] if python.found() else [mlog.red('NO')]) + if not python.found(): if required: raise mesonlib.MesonException('{} not found'.format(name_or_path or 'python')) diff --git a/test cases/python/1 basic/meson.build b/test cases/python/1 basic/meson.build index f9a743379..9c3af10c6 100644 --- a/test cases/python/1 basic/meson.build +++ b/test cases/python/1 basic/meson.build @@ -1,7 +1,7 @@ project('python sample', 'c') py_mod = import('python') -py = py_mod.find_installation() +py = py_mod.find_installation('python3') py_version = py.language_version() if py_version.version_compare('< 3.2') -- cgit v1.2.3 From de48e887b8db039db6e921377b9c34fd6613ad7b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 3 Apr 2019 09:11:07 -0700 Subject: modules/python: Do disabler check after validating inputs This will help developers not introduce bugs (say putting 3 instead of "python3"), and will be useful for the next patch. --- mesonbuild/modules/python.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 693621b57..027d0f773 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -498,9 +498,6 @@ class PythonModule(ExtensionModule): def find_installation(self, interpreter, state, args, kwargs): feature_check = FeatureNew('Passing "feature" option to find_installation', '0.48.0') disabled, required, feature = extract_required_kwarg(kwargs, state.subproject, feature_check) - if disabled: - mlog.log('find_installation skipped: feature', mlog.bold(feature), 'disabled') - return ExternalProgramHolder(NonExistingExternalProgram()) if len(args) > 1: raise InvalidArguments('find_installation takes zero or one positional argument.') @@ -511,6 +508,10 @@ class PythonModule(ExtensionModule): if not isinstance(name_or_path, str): raise InvalidArguments('find_installation argument must be a string.') + if disabled: + mlog.log('find_installation skipped: feature', mlog.bold(feature), 'disabled') + return ExternalProgramHolder(NonExistingExternalProgram()) + if not name_or_path: python = ExternalProgram('python3', mesonlib.python_command) else: -- cgit v1.2.3 From a710b83a677428e4cef29e86aead7f66ee8d183d Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 3 Apr 2019 09:13:55 -0700 Subject: modules/python: normalize output for disabled by feature Instead of printing a message about how python was skipped, print the normal 'Program foo found:' message, with a "disabled by feature" message added. --- mesonbuild/modules/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 027d0f773..bd69244d3 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -509,7 +509,7 @@ class PythonModule(ExtensionModule): raise InvalidArguments('find_installation argument must be a string.') if disabled: - mlog.log('find_installation skipped: feature', mlog.bold(feature), 'disabled') + mlog.log('Program', name_or_path or 'python', 'found:', mlog.red('NO'), '(disabled by:', mlog.bold(feature), ')') return ExternalProgramHolder(NonExistingExternalProgram()) if not name_or_path: -- cgit v1.2.3