|
8 | 8 | # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights |
9 | 9 | # not expressly granted therein are reserved by Shotgun Software Inc. |
10 | 10 |
|
| 11 | +import os |
11 | 12 | import sys |
12 | 13 | import warnings |
13 | 14 |
|
14 | | -if sys.version_info < (3, 9): |
| 15 | +if sys.version_info < (3, 7): |
| 16 | + if os.environ.get("SHOTGUN_ALLOW_OLD_PYTHON", "0") != "1": |
| 17 | + # This is our preferred default behavior when using an old |
| 18 | + # unsupported Python version. |
| 19 | + # This way, we can control where the exception is raised, and it provides a |
| 20 | + # comprehensive error message rather than having users facing a random |
| 21 | + # Python traceback and trying to understand this is due to using an |
| 22 | + # unsupported Python version. |
| 23 | + |
| 24 | + raise RuntimeError("This module requires Python version 3.7 or higher.") |
| 25 | + |
| 26 | + warnings.warn( |
| 27 | + "Python versions older than 3.7 are no longer supported as of January " |
| 28 | + "2023. Since the SHOTGUN_ALLOW_OLD_PYTHON variable is enabled, this " |
| 29 | + "module is raising a warning instead of an exception. " |
| 30 | + "However, it is very likely that this module will not be able to work " |
| 31 | + "on this Python version.", |
| 32 | + RuntimeWarning, |
| 33 | + stacklevel=2, |
| 34 | + ) |
| 35 | +elif sys.version_info < (3, 9): |
15 | 36 | warnings.warn( |
16 | | - "Python versions older than 3.9 are no longer supported since 2025-03 " |
17 | | - "and compatibility will be removed at any time after 2026-01. " |
18 | | - "Please update to Python 3.9 or a newer supported version.", |
| 37 | + "Python versions older than 3.9 are no longer supported as of March " |
| 38 | + "2025 and compatibility will be discontinued after March 2026. " |
| 39 | + "Please update to Python 3.11 or any other supported version.", |
19 | 40 | DeprecationWarning, |
20 | 41 | stacklevel=2, |
21 | 42 | ) |
|
0 commit comments