Skip to content

Drop python3.7 support for SAM-T #3403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
os:
- ubuntu-latest
python:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand Down
23 changes: 11 additions & 12 deletions DEVELOPMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Environment setup
-----------------
### 1. Install Python versions

Our officially supported Python versions are 3.7, 3.8, 3.9 and 3.10.
Our officially supported Python versions are 3.8, 3.9 and 3.10.
Our CI/CD pipeline is setup to run unit tests against Python 3 versions. Make sure you test it before sending a Pull Request.
See [Unit testing with multiple Python versions](#unit-testing-with-multiple-python-versions).

Expand All @@ -40,12 +40,11 @@ easily setup multiple Python versions. For
1. Install PyEnv -
`curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash`
1. Restart shell so the path changes take effect - `exec $SHELL`
1. `pyenv install 3.7.16`
1. `pyenv install 3.8.16`
1. `pyenv install 3.9.16`
1. `pyenv install 3.10.9`
3. Make Python versions available in the project:
`pyenv local 3.7.16 3.8.16 3.9.16 3.10.9`
`pyenv local 3.8.16 3.9.16 3.10.9`

Note: also make sure the following lines were written into your `.bashrc` (or `.zshrc`, depending on which shell you are using):
```
Expand All @@ -66,7 +65,7 @@ can be found [here](https://black.readthedocs.io/en/stable/editor_integration.ht
Since black is installed in virtualenv, when you follow [this instruction](https://black.readthedocs.io/en/stable/editor_integration.html), `which black` might give you this

```bash
(sam37) $ where black
(sam38) $ where black
/Users/<username>/.pyenv/shims/black
```

Expand All @@ -77,11 +76,11 @@ and this will happen:
pyenv: black: command not found

The `black' command exists in these Python versions:
3.7.9/envs/sam37
sam37
3.8.16/envs/sam38
sam38
```

A simple workaround is to use `/Users/<username>/.pyenv/versions/sam37/bin/black`
A simple workaround is to use `/Users/<username>/.pyenv/versions/sam38/bin/black`
instead of `/Users/<username>/.pyenv/shims/black`.

#### Pre-commit
Expand All @@ -99,15 +98,15 @@ handy plugin that can create virtualenv.
Depending on the python version, the following commands would change to
be the appropriate python version.

1. Create Virtualenv `sam37` for Python3.7: `pyenv virtualenv 3.7.9 sam37`
1. Activate Virtualenv: `pyenv activate sam37`
1. Create Virtualenv `sam38` for Python3.8: `pyenv virtualenv 3.8.16 sam38`
1. Activate Virtualenv: `pyenv activate sam38`

### 4. Install dev version of SAM transform

We will install a development version of SAM transform from source into the
virtualenv.

1. Activate Virtualenv: `pyenv activate sam37`
1. Activate Virtualenv: `pyenv activate sam38`
1. Install dev version of SAM transform: `make init`

Running tests
Expand All @@ -121,8 +120,8 @@ Run `make test` or `make test-fast`. Once all tests pass make sure to run

### Unit testing with multiple Python versions

Currently, our officially supported Python versions are 3.7, 3.8, 3.9 and 3.10. For the most
part, code that works in Python3.7 will work in Pythons 3.8, 3.9 and 3.10. You only run into problems if you are
Currently, our officially supported Python versions are 3.8, 3.9 and 3.10. For the most
part, code that works in Python3.8 will work in Pythons 3.9 and 3.10. You only run into problems if you are
trying to use features released in a higher version (for example features introduced into Python3.10
will not work in Python3.9). If you want to test in many versions, you can create a virtualenv for
each version and flip between them (sourcing the activate script). Typically, we run all tests in
Expand Down
2 changes: 1 addition & 1 deletion HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Check out the [latest specification](versions/2016-10-31.md) for details on how
You could also use the [aws-sam-cli](https://github.com/awslabs/aws-sam-cli) to get started

```shell
$ sam init --runtime python3.7
$ sam init --runtime python3.8
```
## Packing Artifacts
Before you can deploy a SAM template, you should first upload your Lambda
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ For a more thorough introduction, see the [this tutorial](https://docs.aws.amazo

### Setting up development environment

You'll need to have Python 3.7+ installed.
You'll need to have Python 3.8+ installed.

Create a [virtual environment](https://docs.python.org/3/library/venv.html):

Expand Down
4 changes: 1 addition & 3 deletions bin/transform-test-error-json-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import sys
from pathlib import Path

from typing_extensions import Final

# To allow this script to be executed from other directories
sys.path.insert(0, str(Path(__file__).absolute().parent.parent))

import json
from typing import Type
from typing import Final, Type

from bin._file_formatter import FileFormatter

Expand Down
4 changes: 1 addition & 3 deletions integration/helpers/deployer/utils/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Wrapper to generated colored messages for printing in Terminal
This was ported over from the sam-cli repo
"""
from typing import Dict

from typing_extensions import Literal
from typing import Dict, Literal

SupportedColor = Literal["red", "green", "yellow"]

Expand Down
4 changes: 2 additions & 2 deletions integration/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ select = [
"UP", # pyupgrade
]

# Mininal python version we support is 3.7
target-version = "py37"
# Mininal python version we support is 3.8
target-version = "py38"

[per-file-ignores]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 120
target_version = ['py37', 'py38', 'py39', 'py310']
target_version = ['py38', 'py39', 'py310']
exclude = '''

(
Expand Down
2 changes: 0 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ filterwarnings =
# From our own tests
ignore:__init__ is deprecated and will be removed in a future release:DeprecationWarning
ignore:deprecated_function is deprecated and will be removed in a future release, please use replacement_function:DeprecationWarning
# Python 3.7 deprecation
ignore::boto3.exceptions.PythonDeprecationWarning
# https://github.com/pytest-dev/pytest-xdist/issues/825#issuecomment-1292450429
ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning
# Pytest warnings
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
boto3>=1.19.5,==1.*
jsonschema<5,>=3.2 # TODO: evaluate risk of removing jsonschema 3.x support
typing_extensions>=4.4,<5 # 3.7 doesn't have Literal
typing_extensions>=4.4 # 3.8 doesn't have Required, TypeGuard and ParamSpec

# resource validation & schema generation
pydantic>=1.8,<3
6 changes: 1 addition & 5 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tenacity~=8.0
requests~=2.28

# formatter
black==23.3.0 # 23.3.0 is the last version supporting python 3.7
black==23.10.1
ruamel.yaml==0.17.21 # It can parse yaml while perserving comments

# type check
Expand All @@ -29,7 +29,3 @@ mypy~=1.3.0
boto3-stubs[appconfig,serverlessrepo]>=1.19.5,==1.*
types-PyYAML~=6.0
types-jsonschema~=3.2

# Check package version (backport importlib.metadata for python 3.7)
# https://docs.python.org/3/library/importlib.metadata.html
importlib_metadata; python_version < '3.8'
4 changes: 2 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ ignore = [
"G004",
]

# Mininal python version we support is 3.7
target-version = "py37"
# Mininal python version we support is 3.8
target-version = "py38"

[per-file-ignores]
# python scripts in bin/ needs some python path configurations before import
Expand Down
4 changes: 2 additions & 2 deletions samtranslator/internal/model/appsync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Optional, TypedDict, Union

from typing_extensions import Required, TypedDict
from typing_extensions import Required

from samtranslator.model import GeneratedProperty, Resource
from samtranslator.model.intrinsics import fnGetAtt, ref
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Dict, List, Optional, Union

from typing_extensions import Literal
from typing import Dict, List, Literal, Optional, Union

from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector
from samtranslator.internal.schema_source.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Any, Dict, Optional, Union

from typing_extensions import Literal
from typing import Any, Dict, Literal, Optional, Union

from samtranslator.internal.schema_source.common import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from typing import List, Optional, Union

from typing_extensions import Literal
from typing import List, Literal, Optional, Union

from samtranslator.internal.schema_source.common import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Dict, List, Optional, Union

from typing_extensions import Literal
from typing import Dict, List, Literal, Optional, Union

from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector
from samtranslator.internal.schema_source.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from typing import Dict, List, Optional, Union

from typing_extensions import Literal
from typing import Dict, List, Literal, Optional, Union

from samtranslator.internal.schema_source.common import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Dict, List, Optional, Union

from typing_extensions import Literal
from typing import Dict, List, Literal, Optional, Union

from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector
from samtranslator.internal.schema_source.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Optional, Union

from typing_extensions import Literal
from typing import Literal, Optional, Union

from samtranslator.internal.schema_source.common import (
BaseModel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Any, Dict, Optional

from typing_extensions import Literal
from typing import Any, Dict, Literal, Optional

from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector
from samtranslator.internal.schema_source.common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Dict, List, Optional, Union

from typing_extensions import Literal
from typing import Dict, List, Literal, Optional, Union

from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector
from samtranslator.internal.schema_source.common import (
Expand Down
4 changes: 1 addition & 3 deletions samtranslator/internal/schema_source/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import json
from functools import partial
from pathlib import Path
from typing import Any, Dict, List, Optional, TypeVar, Union

from typing_extensions import Literal
from typing import Any, Dict, List, Literal, Optional, TypeVar, Union

from samtranslator.compat import pydantic
from samtranslator.model.types import PassThrough
Expand Down
4 changes: 1 addition & 3 deletions samtranslator/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import logging
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Any, Dict, List, Optional, Union

from typing_extensions import TypedDict
from typing import Any, Dict, List, Optional, TypedDict, Union

from samtranslator.internal.deprecation_control import deprecated

Expand Down
4 changes: 1 addition & 3 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
""" SAM macro definitions """
import copy
from contextlib import suppress
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast

from typing_extensions import Literal
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, cast

import samtranslator.model.eventsources
import samtranslator.model.eventsources.cloudwatchlogs
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def read_requirements(req="base.txt"):
"NOTICE",
"THIRD_PARTY_LICENSES",
),
python_requires=">=3.7, <=4.0, !=4.0",
python_requires=">=3.8, <=4.0, !=4.0",
install_requires=read_requirements("base.txt"),
include_package_data=True,
extras_require={"dev": read_requirements("dev.txt")},
Expand All @@ -93,7 +93,6 @@ def read_requirements(req="base.txt"):
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
4 changes: 2 additions & 2 deletions tests/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ select = [
"UP", # pyupgrade
]

# Mininal python version we support is 3.7
target-version = "py37"
# Mininal python version we support is 3.8
target-version = "py38"

[per-file-ignores]

Expand Down