From 2b37b646a49e234e290e729f3912da6bb9297559 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 21 Aug 2024 10:23:44 -0700 Subject: [PATCH] Add Python version specific recommendations to installation error. --- setup.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b5df81d18..d7c9af8ee 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,30 @@ python_version = sys.version_info[:2] -assert python_version >= (3, 7), "The New Relic Python agent only supports Python 3.7+." +if python_version >= (3, 7): + pass +else: + error_msg = "The New Relic Python agent only supports Python 3.7+. We recommend upgrading to a newer version of Python." + + try: + # Lookup table for the last agent versions to support each Python version. + last_supported_version_lookup = { + (2, 6): "3.4.0.95", + (2, 7): "9.13.0", + (3, 3): "3.4.0.95", + (3, 4): "4.20.0.120", + (3, 5): "5.24.0.153", + (3, 6): "7.16.0.178", + } + last_supported_version = last_supported_version_lookup.get(python_version, None) + + if last_supported_version: + python_version_str = "%s.%s" % (python_version[0], python_version[1]) + error_msg += " The last agent version to support Python %s was v%s." % (python_version_str, last_supported_version) + except Exception: + pass + + raise RuntimeError(error_msg) with_setuptools = False