Skip to content

Commit c0163e5

Browse files
sriram-mvroger-zhanggreedham-awsvicheey
authored
feat: Python UV workflow (aws#756)
* feat: Python UV workflow Core Features: * Intelligent handling of pyproject.toml with automatic uv.lock detection * Multi-format support: pyproject.toml, requirements.txt, and requirements-*.txt variants * Lock file optimization: Automatic uv.lock usage for reproducible builds when available * Platform targeting: Lambda-compatible builds for x86_64 and ARM64 architectures * Python version control: Precise Python version targeting via UV's --python flags UV Functionality: * `uv sync --python X.Y` for lock-based builds (pyproject.toml + uv.lock) * `uv lock && uv export` workflow for pyproject.toml without lock files * `uv pip install --python-version X.Y --python-platform` for requirements.txt * Proper virtual environment handling and site-packages extraction Documentation: * Complete DESIGN.md with architecture overview and usage patterns * Accurate API documentation reflecting constructor + method call pattern * Smart dispatch logic clearly explained with examples * Updated to match actual implementation (no outdated references) Compatibility: * Compatible with existing Lambda Builders interface * Supports standard build parameters (source_dir, artifacts_dir, scratch_dir) * Runtime parameter properly extracted and used for Python version targeting * Architecture parameter mapped to UV platform specifications * tests: additional functional tests for python_uv * fix(): address comments * fix: address comments - round 2 * fix(additional tests cases): python-uv * chore(README.md): update with python uv support * fix: have lock file builds run in cwd * fix: misc pr feedback * cd: setup uv for unit tests * nit: format * test: remove hardcoded pathsep --------- Co-authored-by: Roger Zhang <roger.zhang.cs@gmail.com> Co-authored-by: Reed Hamilton <reedham@amazon.com> Co-authored-by: vicheey <181402101+vicheey@users.noreply.github.com>
1 parent 14dbe36 commit c0163e5

29 files changed

Lines changed: 3004 additions & 5 deletions

.github/workflows/build.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
- java-maven-integration
3131
- java-gradle-integration
3232
- custom-make-integration
33-
- python-integration
33+
- python-pip-integration
34+
- python-uv-integration
3435
- ruby-integration
3536
- dotnet-integration
3637
- rust-cargo-lambda-integration
@@ -44,7 +45,8 @@ jobs:
4445
needs.java-maven-integration.result != 'success' ||
4546
needs.java-gradle-integration.result != 'success' ||
4647
needs.custom-make-integration.result != 'success' ||
47-
needs.python-integration.result != 'success' ||
48+
needs.python-pip-integration.result != 'success' ||
49+
needs.python-uv-integration.result != 'success' ||
4850
needs.ruby-integration.result != 'success' ||
4951
needs.dotnet-integration.result != 'success' ||
5052
needs.rust-cargo-lambda-integration.result != 'success'
@@ -74,6 +76,7 @@ jobs:
7476
- uses: actions/setup-python@v6
7577
with:
7678
python-version: ${{ matrix.python }}
79+
- uses: astral-sh/setup-uv@v4
7780
- name: Unit Testing
7881
run: make pr
7982
- name: Functional Testing
@@ -248,8 +251,37 @@ jobs:
248251
- run: make init
249252
- run: pytest -vv tests/integration/workflows/custom_make
250253

251-
python-integration:
252-
name: ${{ matrix.os }} / ${{ matrix.python }} / python
254+
python-pip-integration:
255+
name: ${{ matrix.os }} / ${{ matrix.python }} / python-pip
256+
if: github.repository_owner == 'aws'
257+
runs-on: ${{ matrix.os }}
258+
strategy:
259+
fail-fast: false
260+
matrix:
261+
os:
262+
- ubuntu-latest
263+
- windows-latest
264+
python:
265+
- "3.9"
266+
- "3.10"
267+
- "3.11"
268+
- "3.12"
269+
- "3.13"
270+
- "3.14"
271+
steps:
272+
- uses: actions/checkout@v4
273+
- uses: actions/setup-python@v5
274+
with:
275+
python-version: ${{ matrix.python }}
276+
- run: |
277+
python -m pip install --upgrade pip
278+
pip install --upgrade setuptools
279+
if: ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.python }} == '3.12'
280+
- run: make init
281+
- run: pytest -vv tests/integration/workflows/python_pip
282+
283+
python-uv-integration:
284+
name: ${{ matrix.os }} / ${{ matrix.python }} / python-uv
253285
if: github.repository_owner == 'aws'
254286
runs-on: ${{ matrix.os }}
255287
strategy:
@@ -274,8 +306,13 @@ jobs:
274306
python -m pip install --upgrade pip
275307
pip install --upgrade setuptools
276308
if: ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.python }} == '3.12'
309+
# Install UV for python_uv workflow tests
310+
- name: Install UV
311+
uses: astral-sh/setup-uv@v4
312+
with:
313+
enable-cache: true
277314
- run: make init
278-
- run: pytest -vv tests/integration/workflows/python_pip
315+
- run: pytest -vv tests/integration/workflows/python_uv
279316

280317
ruby-integration:
281318
name: ${{ matrix.os }} / ${{ matrix.python }} / ruby

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Lambda Builders currently contains the following workflows
1414
* Java with Maven
1515
* Dotnet with amazon.lambda.tools
1616
* Python with Pip
17+
* Python with Uv (beta)
1718
* Javascript with Npm
1819
* Typescript with esbuild
1920
* Ruby with Bundler

aws_lambda_builders/workflows/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
import aws_lambda_builders.workflows.nodejs_npm
1111
import aws_lambda_builders.workflows.nodejs_npm_esbuild
1212
import aws_lambda_builders.workflows.python_pip
13+
import aws_lambda_builders.workflows.python_uv
1314
import aws_lambda_builders.workflows.ruby_bundler
1415
import aws_lambda_builders.workflows.rust_cargo

0 commit comments

Comments
 (0)