aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-08-31 15:06:20 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-09-02 10:37:40 +0000
commit4ad4565ddd025570583f877ebdeb7c360509bf93 (patch)
treedc14adf9a3662aac0c38bd553d46d551efda4ead
parent0ec8bebae81d941fc86cbf2d971aa2867428a8de (diff)
downloadmeson-4ad4565ddd025570583f877ebdeb7c360509bf93.zip
meson-4ad4565ddd025570583f877ebdeb7c360509bf93.tar.gz
meson-4ad4565ddd025570583f877ebdeb7c360509bf93.tar.bz2
Add a notice about Python 3.5 support
This will be printed in bold at the end of interactive meson sub-commands that won't be parsed by a program. Specifically: setup, compile, test, and install. NOTICE: You are using [...]
-rw-r--r--mesonbuild/mesonmain.py16
-rw-r--r--mesonbuild/mlog.py9
2 files changed, 21 insertions, 4 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index fc9d6a6..e07c0df 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -38,7 +38,7 @@ class CommandLineParser:
self.commands = {}
self.hidden_commands = []
self.parser = argparse.ArgumentParser(prog='meson', formatter_class=self.formatter)
- self.subparsers = self.parser.add_subparsers(title='Commands',
+ self.subparsers = self.parser.add_subparsers(title='Commands', dest='command',
description='If no command is specified it defaults to setup command.')
self.add_command('setup', msetup.add_arguments, msetup.run,
help_msg='Configure the project')
@@ -111,6 +111,7 @@ class CommandLineParser:
return 0
def run(self, args):
+ print_py35_notice = False
# If first arg is not a known command, assume user wants to run the setup
# command.
known_commands = list(self.commands.keys()) + ['-h', '--help']
@@ -119,14 +120,22 @@ class CommandLineParser:
# Hidden commands have their own parser instead of using the global one
if args[0] in self.hidden_commands:
- parser = self.commands[args[0]]
+ command = args[0]
+ parser = self.commands[command]
args = args[1:]
else:
parser = self.parser
+ command = None
args = mesonlib.expand_arguments(args)
options = parser.parse_args(args)
+ if command is None:
+ command = options.command
+
+ if command in ('setup', 'compile', 'test', 'install') and sys.version_info < (3, 6):
+ print_py35_notice = True
+
try:
return options.run_func(options)
except MesonException as e:
@@ -143,6 +152,9 @@ class CommandLineParser:
traceback.print_exc()
return 2
finally:
+ if print_py35_notice:
+ mlog.notice('You are using Python 3.5 which is EOL. Starting with v0.57, '
+ 'Meson will require Python 3.6 or newer', fatal=False)
mlog.shutdown()
def run_script_command(script_name, script_args):
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 1e5a105..9c19427 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -255,8 +255,10 @@ def _log_error(severity: str, *rargs: T.Union[str, AnsiDecorator],
# The typing requirements here are non-obvious. Lists are invariant,
# therefore T.List[A] and T.List[T.Union[A, B]] are not able to be joined
- if severity == 'warning':
- label = [yellow('WARNING:')] # type: T.List[T.Union[str, AnsiDecorator]]
+ if severity == 'notice':
+ label = [bold('NOTICE:')] # type: T.List[T.Union[str, AnsiDecorator]]
+ elif severity == 'warning':
+ label = [yellow('WARNING:')]
elif severity == 'error':
label = [red('ERROR:')]
elif severity == 'deprecation':
@@ -295,6 +297,9 @@ def warning(*args: T.Union[str, AnsiDecorator], **kwargs: T.Any) -> None:
def deprecation(*args: T.Union[str, AnsiDecorator], **kwargs: T.Any) -> None:
return _log_error('deprecation', *args, **kwargs, is_error=True)
+def notice(*args: T.Union[str, AnsiDecorator], **kwargs: T.Any) -> None:
+ return _log_error('notice', *args, **kwargs, is_error=False)
+
def get_relative_path(target: Path, current: Path) -> Path:
"""Get the path to target from current"""
# Go up "current" until we find a common ancestor to target