|
| 1 | +# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +"""Contains logic for checking ESDK and Python Version""" |
| 14 | +import sys |
| 15 | +import warnings |
| 16 | + |
| 17 | +DEPRECATION_DATE_MAP = {"1.x": "2022-06-30", "2.x": "2022-07-01"} |
| 18 | + |
| 19 | + |
| 20 | +def _warn_deprecated_python(): |
| 21 | + """Template for deprecation of Python warning.""" |
| 22 | + deprecated_versions = { |
| 23 | + (2, 7): {"date": DEPRECATION_DATE_MAP["2.x"]}, |
| 24 | + (3, 4): {"date": DEPRECATION_DATE_MAP["2.x"]}, |
| 25 | + (3, 5): {"date": "2021-11-10"}, |
| 26 | + } |
| 27 | + py_version = (sys.version_info.major, sys.version_info.minor) |
| 28 | + minimum_version = (3, 6) |
| 29 | + |
| 30 | + if py_version in deprecated_versions: |
| 31 | + params = deprecated_versions[py_version] |
| 32 | + warning = ( |
| 33 | + "aws-encryption-sdk will no longer support Python {}.{} " |
| 34 | + "starting {}. To continue receiving service updates, " |
| 35 | + "bug fixes, and security updates please upgrade to Python {}.{} or " |
| 36 | + "later. For more information, see SUPPORT_POLICY.rst: " |
| 37 | + "https://github.com/aws/aws-encryption-sdk-python/blob/master/SUPPORT_POLICY.rst" |
| 38 | + ).format(py_version[0], py_version[1], minimum_version[0], minimum_version[1], params["date"]) |
| 39 | + warnings.warn(warning, DeprecationWarning) |
0 commit comments