From 1a12ddbd2da6964cc9f2ac0e7d71c6f043ab68f7 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 6 Oct 2022 23:42:34 +0200 Subject: Add a warning on Python 2.7 deprecation (#33052) Co-authored-by: alalazo Co-authored-by: Todd Gamblin --- lib/spack/spack/main.py | 6 ++++++ lib/spack/spack/test/cmd/commands.py | 3 +++ 2 files changed, 9 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index 78a0d47519..ed8604f1ff 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -547,6 +547,12 @@ def setup_main_options(args): # Assign a custom function to show warnings warnings.showwarning = send_warning_to_tty + if sys.version_info[:2] == (2, 7): + warnings.warn( + "Python 2.7 support is deprecated and will be removed in Spack v0.20.\n" + " Please move to Python 3.6 or higher." + ) + # Set up environment based on args. tty.set_verbose(args.verbose) tty.set_debug(args.debug) diff --git a/lib/spack/spack/test/cmd/commands.py b/lib/spack/spack/test/cmd/commands.py index d972f86d7f..da20927589 100644 --- a/lib/spack/spack/test/cmd/commands.py +++ b/lib/spack/spack/test/cmd/commands.py @@ -22,6 +22,9 @@ parser = spack.main.make_argument_parser() spack.main.add_all_commands(parser) +@pytest.mark.skipif( + sys.version_info[:2] == (2, 7), reason="Fails as the output contains a warning on Python 2.7" +) def test_names(): """Test default output of spack commands.""" out1 = commands().strip().split("\n") -- cgit v1.2.3-70-g09d2