Skip to content

Commit d68a6b5

Browse files
mndevecibriensea
andauthored
feat: add python3.10 support (#468)
* feat: add python3.10 support (#32) * Add python3.10 support. * add support for py3.10 * add ci jobs for py3.10 * Fix python3.10 workflows. --------- Co-authored-by: Mehmet Nuri Deveci <[email protected]> * Update DESIGN.md * update test cases with py310 differences --------- Co-authored-by: Sean O Brien <[email protected]>
1 parent 49c5cfb commit d68a6b5

File tree

8 files changed

+72
-37
lines changed

8 files changed

+72
-37
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
- "3.7"
5959
- "3.8"
6060
- "3.9"
61+
- "3.10"
6162
steps:
6263
- uses: actions/checkout@v3
6364
- uses: actions/setup-python@v4
@@ -82,6 +83,7 @@ jobs:
8283
- "3.7"
8384
- "3.8"
8485
- "3.9"
86+
- "3.10"
8587
npm:
8688
- 8
8789
- 9
@@ -113,6 +115,7 @@ jobs:
113115
- "3.7"
114116
- "3.8"
115117
- "3.9"
118+
- "3.10"
116119
npm:
117120
- 8
118121
- 9
@@ -144,6 +147,7 @@ jobs:
144147
- "3.7"
145148
- "3.8"
146149
- "3.9"
150+
- "3.10"
147151
steps:
148152
- uses: actions/checkout@v3
149153
- uses: actions/setup-python@v4
@@ -166,9 +170,10 @@ jobs:
166170
- ubuntu-latest
167171
- windows-latest
168172
python:
169-
- "3.9"
170-
- "3.8"
171173
- "3.7"
174+
- "3.8"
175+
- "3.9"
176+
- "3.10"
172177
steps:
173178
- uses: actions/checkout@v3
174179
- uses: actions/setup-python@v4
@@ -194,9 +199,10 @@ jobs:
194199
- ubuntu-latest
195200
- windows-latest
196201
python:
197-
- "3.9"
198-
- "3.8"
199202
- "3.7"
203+
- "3.8"
204+
- "3.9"
205+
- "3.10"
200206
steps:
201207
- uses: actions/checkout@v3
202208
- uses: actions/setup-python@v4
@@ -220,9 +226,10 @@ jobs:
220226
- ubuntu-latest
221227
- windows-latest
222228
python:
223-
- "3.9"
224-
- "3.8"
225229
- "3.7"
230+
- "3.8"
231+
- "3.9"
232+
- "3.10"
226233
steps:
227234
- uses: actions/checkout@v3
228235
- uses: actions/setup-python@v4
@@ -242,9 +249,10 @@ jobs:
242249
- ubuntu-latest
243250
- windows-latest
244251
python:
245-
- "3.9"
246-
- "3.8"
247252
- "3.7"
253+
- "3.8"
254+
- "3.9"
255+
- "3.10"
248256
steps:
249257
- uses: actions/checkout@v3
250258
- uses: actions/setup-python@v4
@@ -264,9 +272,10 @@ jobs:
264272
- ubuntu-latest
265273
- windows-latest
266274
python:
267-
- "3.9"
268-
- "3.8"
269275
- "3.7"
276+
- "3.8"
277+
- "3.9"
278+
- "3.10"
270279
ruby:
271280
- "3.1"
272281
- "2.7"
@@ -292,9 +301,10 @@ jobs:
292301
- ubuntu-latest
293302
- windows-latest
294303
python:
295-
- "3.9"
296-
- "3.8"
297304
- "3.7"
305+
- "3.8"
306+
- "3.9"
307+
- "3.10"
298308
steps:
299309
- uses: actions/checkout@v3
300310
- uses: actions/setup-python@v4

aws_lambda_builders/validator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"python3.7": [X86_64],
1818
"python3.8": [ARM64, X86_64],
1919
"python3.9": [ARM64, X86_64],
20+
"python3.10": [ARM64, X86_64],
2021
"ruby2.7": [ARM64, X86_64],
2122
"java8": [ARM64, X86_64],
2223
"java11": [ARM64, X86_64],

aws_lambda_builders/workflows/python_pip/DESIGN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def build_dependencies(artifacts_dir_path,
4949
5050
:type runtime: str
5151
:param runtime: Python version to build dependencies for. This can
52-
either be python3.6, python3.7, python3.8 or python3.9. These are
52+
either be python3.7, python3.8, python3.9 or python3.10. These are
5353
currently the only supported values.
5454
5555
:type ui: :class:`lambda_builders.actions.python_pip.utils.UI`

aws_lambda_builders/workflows/python_pip/packager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def get_lambda_abi(runtime):
8484
"python3.7": "cp37m",
8585
"python3.8": "cp38",
8686
"python3.9": "cp39",
87+
"python3.10": "cp310",
8788
}
8889

8990
if runtime not in supported:
@@ -98,7 +99,7 @@ def __init__(self, runtime, osutils=None, dependency_builder=None, architecture=
9899
99100
:type runtime: str
100101
:param runtime: Python version to build dependencies for. This can
101-
either be python3.7, python3.8 or python3.9. These are currently the
102+
either be python3.7, python3.8, python3.9 or python3.10. These are currently the
102103
only supported values.
103104
104105
:type osutils: :class:`lambda_builders.utils.OSUtils`

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def read_version():
6161
"Programming Language :: Python :: 3.7",
6262
"Programming Language :: Python :: 3.8",
6363
"Programming Language :: Python :: 3.9",
64+
"Programming Language :: Python :: 3.10",
6465
"Topic :: Internet",
6566
"Topic :: Software Development :: Build Tools",
6667
"Topic :: Utilities",

tests/integration/workflows/python_pip/test_python_pip.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
logger = logging.getLogger("aws_lambda_builders.workflows.python_pip.workflow")
1919
IS_WINDOWS = platform.system().lower() == "windows"
2020
NOT_ARM = platform.processor() != "aarch64"
21-
ARM_RUNTIMES = {"python3.8", "python3.9"}
21+
ARM_RUNTIMES = {"python3.8", "python3.9", "python3.10"}
2222

2323

2424
@parameterized_class(("experimental_flags",), [([]), ([EXPERIMENTAL_FLAG_BUILD_PERFORMANCE])])
@@ -60,6 +60,7 @@ def setUp(self):
6060
"python3.7": "python3.8",
6161
"python3.8": "python3.9",
6262
"python3.9": "python3.7",
63+
"python3.10": "python3.9",
6364
}
6465

6566
def tearDown(self):
@@ -92,33 +93,43 @@ def test_must_build_python_project(self):
9293
experimental_flags=self.experimental_flags,
9394
)
9495

95-
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
96-
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})
96+
if self.runtime == "python3.10":
97+
self.check_architecture_in("numpy-1.23.5.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"])
98+
expected_files = self.test_data_files.union({"numpy", "numpy-1.23.5.dist-info", "numpy.libs"})
99+
else:
100+
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
101+
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})
97102

98103
output_files = set(os.listdir(self.artifacts_dir))
99104
self.assertEqual(expected_files, output_files)
100105

101106
def test_must_build_python_project_python3_binary(self):
102107
python_paths = which("python")
103-
executable_dir = pathlib.Path(tempfile.gettempdir())
104-
new_python_path = executable_dir.joinpath("python3")
105-
os.symlink(python_paths[0], new_python_path)
106-
# Build with access to the newly symlinked python3 binary.
107-
self.builder.build(
108-
self.source_dir,
109-
self.artifacts_dir,
110-
self.scratch_dir,
111-
self.manifest_path_valid,
112-
runtime=self.runtime,
113-
experimental_flags=self.experimental_flags,
114-
executable_search_paths=[executable_dir],
115-
)
116-
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
117-
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})
108+
with tempfile.TemporaryDirectory() as executable_dir_str:
109+
executable_dir = pathlib.Path(executable_dir_str)
110+
new_python_path = executable_dir.joinpath("python3")
111+
os.symlink(python_paths[0], new_python_path)
112+
# Build with access to the newly symlinked python3 binary.
113+
self.builder.build(
114+
self.source_dir,
115+
self.artifacts_dir,
116+
self.scratch_dir,
117+
self.manifest_path_valid,
118+
runtime=self.runtime,
119+
experimental_flags=self.experimental_flags,
120+
executable_search_paths=[executable_dir],
121+
)
118122

119-
output_files = set(os.listdir(self.artifacts_dir))
120-
self.assertEqual(expected_files, output_files)
121-
os.unlink(new_python_path)
123+
if self.runtime == "python3.10":
124+
self.check_architecture_in("numpy-1.23.5.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"])
125+
expected_files = self.test_data_files.union({"numpy", "numpy-1.23.5.dist-info", "numpy.libs"})
126+
else:
127+
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2010_x86_64", "manylinux1_x86_64"])
128+
expected_files = self.test_data_files.union({"numpy", "numpy-1.20.3.dist-info", "numpy.libs"})
129+
130+
output_files = set(os.listdir(self.artifacts_dir))
131+
self.assertEqual(expected_files, output_files)
132+
os.unlink(new_python_path)
122133

123134
@skipIf(NOT_ARM, "Skip if not running on ARM64")
124135
def test_must_build_python_project_from_sdist_with_arm(self):
@@ -154,10 +165,15 @@ def test_must_build_python_project_with_arm_architecture(self):
154165
experimental_flags=self.experimental_flags,
155166
)
156167
expected_files = self.test_data_files.union({"numpy", "numpy.libs", "numpy-1.20.3.dist-info"})
168+
if self.runtime == "python3.10":
169+
expected_files = self.test_data_files.union({"numpy", "numpy.libs", "numpy-1.23.5.dist-info"})
157170
output_files = set(os.listdir(self.artifacts_dir))
158171
self.assertEqual(expected_files, output_files)
159172

160-
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2014_aarch64"])
173+
if self.runtime == "python3.10":
174+
self.check_architecture_in("numpy-1.23.5.dist-info", ["manylinux2014_aarch64"])
175+
else:
176+
self.check_architecture_in("numpy-1.20.3.dist-info", ["manylinux2014_aarch64"])
161177

162178
def test_mismatch_runtime_python_project(self):
163179
# NOTE : Build still works if other versions of python are accessible on the path. eg: /usr/bin/python3.7
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
numpy==1.15.4; python_version == '2.7'
22
numpy==1.17.4; python_version == '3.6'
3-
numpy==1.20.3; python_version >= '3.7'
3+
numpy==1.20.3; python_version == '3.7'
4+
numpy==1.20.3; python_version == '3.8'
5+
numpy==1.20.3; python_version == '3.9'
6+
numpy==1.23.5; python_version == '3.10'

tests/unit/workflows/python_pip/test_packager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ def test_get_lambda_abi_python38(self):
9898
def test_get_lambda_abi_python39(self):
9999
assert "cp39" == get_lambda_abi("python3.9")
100100

101+
def test_get_lambda_abi_python310(self):
102+
assert "cp310" == get_lambda_abi("python3.10")
103+
101104

102105
class TestPythonPipDependencyBuilder(object):
103106
def test_can_call_dependency_builder(self, osutils):

0 commit comments

Comments
 (0)