Skip to content

Commit 4768fba

Browse files
authored
Merge pull request #1221 from newrelic/feature-python-version-warnings
Add Python Version Specific Installation Errors
2 parents 286a714 + 2b37b64 commit 4768fba

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

setup.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,30 @@
1717

1818
python_version = sys.version_info[:2]
1919

20-
assert python_version >= (3, 7), "The New Relic Python agent only supports Python 3.7+."
20+
if python_version >= (3, 7):
21+
pass
22+
else:
23+
error_msg = "The New Relic Python agent only supports Python 3.7+. We recommend upgrading to a newer version of Python."
24+
25+
try:
26+
# Lookup table for the last agent versions to support each Python version.
27+
last_supported_version_lookup = {
28+
(2, 6): "3.4.0.95",
29+
(2, 7): "9.13.0",
30+
(3, 3): "3.4.0.95",
31+
(3, 4): "4.20.0.120",
32+
(3, 5): "5.24.0.153",
33+
(3, 6): "7.16.0.178",
34+
}
35+
last_supported_version = last_supported_version_lookup.get(python_version, None)
36+
37+
if last_supported_version:
38+
python_version_str = "%s.%s" % (python_version[0], python_version[1])
39+
error_msg += " The last agent version to support Python %s was v%s." % (python_version_str, last_supported_version)
40+
except Exception:
41+
pass
42+
43+
raise RuntimeError(error_msg)
2144

2245
with_setuptools = False
2346

0 commit comments

Comments
 (0)