Skip to content

Commit

Permalink
fix: remove python3.6 support (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
mndeveci authored Feb 6, 2023
1 parent 3f84a2b commit c45839b
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 94 deletions.
1 change: 0 additions & 1 deletion aws_lambda_builders/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"nodejs14.x": [ARM64, X86_64],
"nodejs16.x": [ARM64, X86_64],
"nodejs18.x": [ARM64, X86_64],
"python3.6": [X86_64],
"python3.7": [X86_64],
"python3.8": [ARM64, X86_64],
"python3.9": [ARM64, X86_64],
Expand Down
11 changes: 2 additions & 9 deletions aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def __init__(self, version):

def get_lambda_abi(runtime):
supported = {
"python3.6": "cp36m",
"python3.7": "cp37m",
"python3.8": "cp38",
"python3.9": "cp39",
Expand All @@ -100,7 +99,7 @@ def __init__(self, runtime, osutils=None, dependency_builder=None, architecture=
:type runtime: str
:param runtime: Python version to build dependencies for. This can
either be python3.6, python3.7, python3.8 or python3.9. These are currently the
either be python3.7, python3.8 or python3.9. These are currently the
only supported values.
:type osutils: :class:`lambda_builders.utils.OSUtils`
Expand Down Expand Up @@ -199,8 +198,6 @@ class DependencyBuilder(object):

# Mapping of abi to glibc version in Lambda runtime.
_RUNTIME_GLIBC = {
"cp27mu": (2, 17),
"cp36m": (2, 17),
"cp37m": (2, 17),
"cp38": (2, 26),
"cp39": (2, 26),
Expand Down Expand Up @@ -410,15 +407,11 @@ def _is_compatible_wheel_filename(self, filename):
return True
prefix_version = implementation[:3]
if prefix_version == "cp3":
# Deploying python 3 function which means we need cp36m abi
# Deploying python 3 function which means we need cp37m abi
# We can also accept abi3 which is the CPython 3 Stable ABI and
# will work on any version of python 3.
if abi == lambda_runtime_abi or abi == "abi3":
return True
elif prefix_version == "cp2":
# Deploying to python 2 function which means we need cp27mu abi
if abi == "cp27mu":
return True
# Don't know what we have but it didn't pass compatibility tests.
return False

Expand Down
2 changes: 1 addition & 1 deletion aws_lambda_builders/workflows/python_pip/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def validate(self, runtime_path):
Returns
-------
str
runtime_path, runtime to check eg: /usr/bin/python3.6
runtime_path, runtime to check eg: /usr/bin/python3.9
Raises
------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ignore = ["PLR0913"]

[tool.black]
line-length = 120
target_version = ['py37', 'py36', 'py38']
target_version = ['py37', 'py38', 'py39']
exclude = '''
(
Expand Down
5 changes: 0 additions & 5 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ mock==4.0.2
parameterized==0.7.4
pyelftools~=0.27 # Used to verify the generated Go binary architecture in integration tests (utils.py)


# tempfile backport for < 3.7
backports.tempfile==1.0; python_version<"3.7"


# formatter
black==22.3.0
ruff
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def read_version():
license="Apache License 2.0",
packages=find_packages(exclude=["tests.*", "tests"]),
keywords="AWS Lambda Functions Building",
# Support 3.6 or greater
python_requires=(">=3.6"),
# Support 3.7 or greater
python_requires=(">=3.7"),
entry_points={"console_scripts": ["{}=aws_lambda_builders.__main__:main".format(cmd_name)]},
install_requires=read_requirements("base.txt") + read_requirements("python_pip.txt"),
extras_require={"dev": read_requirements("dev.txt")},
Expand All @@ -58,7 +58,6 @@ def read_version():
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
83 changes: 30 additions & 53 deletions tests/functional/workflows/python_pip/test_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _write_requirements_txt(self, packages, directory):
def _make_appdir_and_dependency_builder(self, reqs, tmpdir, runner, **kwargs):
appdir = str(_create_app_structure(tmpdir))
self._write_requirements_txt(reqs, appdir)
builder = DependencyBuilder(OSUtils(), "python3.6", runner, **kwargs)
builder = DependencyBuilder(OSUtils(), "python3.9", runner, **kwargs)
return appdir, builder

def test_can_build_local_dir_as_whl(self, tmpdir, pip_runner, osutils):
Expand All @@ -215,7 +215,7 @@ def test_can_build_local_dir_as_whl(self, tmpdir, pip_runner, osutils):
pip.set_return_tuple(0, (b"Processing ../foo\n" b" Link is a directory," b" ignoring download_dir"), b"")
pip.wheels_to_build(
expected_args=["--no-deps", "--wheel-dir", mock.ANY, "../foo"],
wheels_to_build=["foo-1.2-cp36-none-any.whl"],
wheels_to_build=["foo-1.2-cp39-none-any.whl"],
)

site_packages = os.path.join(appdir, "site-packages")
Expand All @@ -233,7 +233,7 @@ def test_can_get_whls_all_manylinux(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl", "bar-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl", "bar-1.2-cp39-cp39-manylinux1_x86_64.whl"],
)

site_packages = os.path.join(appdir, ".chalice.", "site-packages")
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_can_expand_purelib_whl(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=["foo-1.2.data/purelib/foo/"],
)

Expand All @@ -296,7 +296,7 @@ def test_can_expand_platlib_whl(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=["foo-1.2.data/platlib/foo/"],
)

Expand All @@ -318,7 +318,7 @@ def test_can_expand_platlib_and_purelib(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=["foo-1.2.data/platlib/foo/", "foo-1.2.data/purelib/bar/"],
)

Expand All @@ -340,7 +340,7 @@ def test_does_ignore_data(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=["foo/placeholder", "foo-1.2.data/data/bar/"],
)

Expand All @@ -363,7 +363,7 @@ def test_does_ignore_include(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=["foo/placeholder", "foo.1.2.data/includes/bar/"],
)

Expand All @@ -386,7 +386,7 @@ def test_does_ignore_scripts(self, tmpdir, pip_runner, osutils):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=["{package_name}/placeholder", "{data_dir}/scripts/bar/placeholder"],
)

Expand All @@ -410,7 +410,7 @@ def test_can_expand_platlib_and_platlib_and_root(self, tmpdir, pip_runner, osuti
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2-cp39-cp39-manylinux1_x86_64.whl"],
whl_contents=[
"{package_name}/placeholder",
"{data_dir}/platlib/bar/placeholder",
Expand All @@ -435,9 +435,9 @@ def test_can_get_whls_mixed_compat(self, tmpdir, osutils, pip_runner):
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=[
"foo-1.0-cp36-none-any.whl",
"bar-1.2-cp36-cp36m-manylinux1_x86_64.whl",
"baz-1.5-cp36-cp36m-linux_x86_64.whl",
"foo-1.0-cp39-none-any.whl",
"bar-1.2-cp39-cp39-manylinux1_x86_64.whl",
"baz-1.5-cp39-cp39-linux_x86_64.whl",
],
)

Expand All @@ -458,7 +458,7 @@ def test_can_support_pep_600_tags(self, tmpdir, osutils, pip_runner):
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=[
"foo-1.2-cp36-cp36m-manylinux_2_12_x86_64.whl",
"foo-1.2-cp39-cp39-manylinux_2_12_x86_64.whl",
],
)

Expand All @@ -479,30 +479,7 @@ def test_can_support_compressed_tags(self, tmpdir, osutils, pip_runner):
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=[
"foo-1.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
],
)

site_packages = os.path.join(appdir, ".chalice.", "site-packages")
with osutils.tempdir() as scratch_dir:
builder.build_site_packages(requirements_file, site_packages, scratch_dir)
installed_packages = os.listdir(site_packages)

pip.validate()
for req in reqs:
assert req in installed_packages

def test_can_get_py27_whls(self, tmpdir, osutils, pip_runner):
reqs = ["foo", "bar", "baz"]
pip, runner = pip_runner
appdir, builder = self._make_appdir_and_dependency_builder(reqs, tmpdir, runner)
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=[
"foo-1.0-cp27-none-any.whl",
"bar-1.2-cp27-none-manylinux1_x86_64.whl",
"baz-1.5-cp27-cp27mu-linux_x86_64.whl",
"foo-1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
],
)

Expand All @@ -523,9 +500,9 @@ def test_can_get_arm64_whls(self, tmpdir, osutils, pip_runner):
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=[
"foo-1.0-cp36-none-any.whl",
"bar-1.2-cp36-none-manylinux2014_aarch64.whl",
"baz-1.5-cp36-cp36m-manylinux2014_aarch64.whl",
"foo-1.0-cp39-none-any.whl",
"bar-1.2-cp39-none-manylinux2014_aarch64.whl",
"baz-1.5-cp39-cp39-manylinux2014_aarch64.whl",
],
)

Expand Down Expand Up @@ -613,10 +590,10 @@ def test_does_fail_on_pep_600_tag_with_unsupported_glibc_version(self, tmpdir, o
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=[
"foo-1.2-cp36-cp36m-manylinux_2_12_x86_64.whl",
"bar-1.2-cp36-cp36m-manylinux_2_999_x86_64.whl",
"baz-1.2-cp36-cp36m-manylinux_3_12_x86_64.whl",
"qux-1.2-cp36-cp36m-manylinux_3_999_x86_64.whl",
"foo-1.2-cp39-cp39-manylinux_2_12_x86_64.whl",
"bar-1.2-cp39-cp39-manylinux_2_999_x86_64.whl",
"baz-1.2-cp39-cp39-manylinux_3_12_x86_64.whl",
"qux-1.2-cp39-cp39-manylinux_3_999_x86_64.whl",
],
)

Expand All @@ -642,7 +619,7 @@ def test_can_replace_incompat_whl(self, tmpdir, osutils, pip_runner):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.0-cp36-none-any.whl", "bar-1.2-cp36-cp36m-macosx_10_6_intel.whl"],
packages=["foo-1.0-cp39-none-any.whl", "bar-1.2-cp39-cp39-macosx_10_6_intel.whl"],
)
# Once the initial download has 1 incompatible whl file. The second,
# more targeted download, finds manylinux1_x86_64 and downloads that.
Expand All @@ -660,7 +637,7 @@ def test_can_replace_incompat_whl(self, tmpdir, osutils, pip_runner):
mock.ANY,
"bar==1.2",
],
packages=["bar-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["bar-1.2-cp39-cp39-manylinux1_x86_64.whl"],
)
site_packages = os.path.join(appdir, ".chalice.", "site-packages")
with osutils.tempdir() as scratch_dir:
Expand Down Expand Up @@ -711,13 +688,13 @@ def test_can_build_sdist(self, tmpdir, osutils, pip_runner):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2.zip", "bar-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2.zip", "bar-1.2-cp39-cp39-manylinux1_x86_64.whl"],
)
# Foo is built from and is pure python so it yields a compatible
# wheel file.
pip.wheels_to_build(
expected_args=["--no-deps", "--wheel-dir", mock.ANY, PathArgumentEndingWith("foo-1.2.zip")],
wheels_to_build=["foo-1.2-cp36-none-any.whl"],
wheels_to_build=["foo-1.2-cp39-none-any.whl"],
)
site_packages = os.path.join(appdir, ".chalice.", "site-packages")
with osutils.tempdir() as scratch_dir:
Expand All @@ -735,7 +712,7 @@ def test_build_sdist_makes_incompatible_whl(self, tmpdir, osutils, pip_runner):
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2.zip", "bar-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2.zip", "bar-1.2-cp39-cp39-manylinux1_x86_64.whl"],
)
# foo is compiled since downloading it failed to get any wheels. And
# the second download for manylinux1_x86_64 wheels failed as well.
Expand All @@ -744,7 +721,7 @@ def test_build_sdist_makes_incompatible_whl(self, tmpdir, osutils, pip_runner):
# can do to install this package.
pip.wheels_to_build(
expected_args=["--no-deps", "--wheel-dir", mock.ANY, PathArgumentEndingWith("foo-1.2.zip")],
wheels_to_build=["foo-1.2-cp36-cp36m-macosx_10_6_intel.whl"],
wheels_to_build=["foo-1.2-cp39-cp39-macosx_10_6_intel.whl"],
)
site_packages = os.path.join(appdir, ".chalice.", "site-packages")
with osutils.tempdir() as scratch_dir:
Expand Down Expand Up @@ -813,7 +790,7 @@ def test_build_into_existing_dir_with_preinstalled_packages(self, tmpdir, osutil
requirements_file = os.path.join(appdir, "requirements.txt")
pip.packages_to_download(
expected_args=["-r", requirements_file, "--dest", mock.ANY, "--exists-action", "i"],
packages=["foo-1.2.zip", "bar-1.2-cp36-cp36m-manylinux1_x86_64.whl"],
packages=["foo-1.2.zip", "bar-1.2-cp39-cp39-manylinux1_x86_64.whl"],
)
pip.packages_to_download(
expected_args=[
Expand All @@ -829,7 +806,7 @@ def test_build_into_existing_dir_with_preinstalled_packages(self, tmpdir, osutil
mock.ANY,
"foo==1.2",
],
packages=["foo-1.2-cp36-cp36m-macosx_10_6_intel.whl"],
packages=["foo-1.2-cp39-cp39-macosx_10_6_intel.whl"],
)

# Add two fake packages foo and bar that have previously been
Expand Down
18 changes: 4 additions & 14 deletions tests/integration/workflows/python_pip/test_python_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def setUp(self):
language=self.builder.capability.language, major=sys.version_info.major, minor=sys.version_info.minor
)
self.runtime_mismatch = {
"python3.6": "python3.7",
"python3.7": "python3.8",
"python3.8": "python3.9",
"python3.9": "python3.7",
Expand Down Expand Up @@ -93,12 +92,8 @@ def test_must_build_python_project(self):
experimental_flags=self.experimental_flags,
)

if self.runtime == "python3.6":
self.check_architecture_in("numpy-1.17.4.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
expected_files = self.test_data_files.union({"numpy", "numpy-1.17.4.dist-info"})
else:
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})

output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
Expand All @@ -118,13 +113,8 @@ def test_must_build_python_project_python3_binary(self):
experimental_flags=self.experimental_flags,
executable_search_paths=[executable_dir],
)

if self.runtime == "python3.6":
self.check_architecture_in("numpy-1.17.4.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
expected_files = self.test_data_files.union({"numpy", "numpy-1.17.4.dist-info"})
else:
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})

output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_validate_with_unsupported_runtime(self):
validator.validate("/usr/bin/unknown_runtime")

def test_validate_with_runtime_and_incompatible_architecture(self):
runtime_list = ["python3.6", "python3.7"]
runtime_list = ["python3.7"]
for runtime in runtime_list:
validator = RuntimeValidator(runtime=runtime, architecture="arm64")
with self.assertRaises(UnsupportedArchitectureError):
Expand Down
Loading

0 comments on commit c45839b

Please sign in to comment.