aws-lambda-builders 1.70.0__tar.gz → 1.71.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. {aws_lambda_builders-1.70.0/aws_lambda_builders.egg-info → aws_lambda_builders-1.71.0}/PKG-INFO +1 -1
  2. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/__init__.py +1 -1
  3. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/utils.py +4 -1
  4. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/DESIGN.md +61 -23
  5. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/packager.py +67 -5
  6. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/utils.py +17 -2
  7. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/workflow.py +55 -3
  8. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0/aws_lambda_builders.egg-info}/PKG-INFO +1 -1
  9. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/LICENSE +0 -0
  10. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/MANIFEST.in +0 -0
  11. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/NOTICE +0 -0
  12. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/README.md +0 -0
  13. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/__main__.py +0 -0
  14. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/actions.py +0 -0
  15. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/architecture.py +0 -0
  16. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/binary_path.py +0 -0
  17. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/builder.py +0 -0
  18. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/exceptions.py +0 -0
  19. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/path_resolver.py +0 -0
  20. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/registry.py +0 -0
  21. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/supported_runtimes.py +0 -0
  22. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/validator.py +0 -0
  23. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflow.py +0 -0
  24. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/__init__.py +0 -0
  25. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/DESIGN.md +0 -0
  26. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/__init__.py +0 -0
  27. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/actions.py +0 -0
  28. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/exceptions.py +0 -0
  29. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/make.py +0 -0
  30. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/utils.py +0 -0
  31. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/validator.py +0 -0
  32. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/custom_make/workflow.py +0 -0
  33. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/DESIGN.md +0 -0
  34. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/__init__.py +0 -0
  35. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/actions.py +0 -0
  36. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli.py +0 -0
  37. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli_resolver.py +0 -0
  38. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/utils.py +0 -0
  39. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/dotnet_clipackage/workflow.py +0 -0
  40. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/DESIGN.md +0 -0
  41. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/__init__.py +0 -0
  42. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/actions.py +0 -0
  43. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/builder.py +0 -0
  44. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/utils.py +0 -0
  45. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/validator.py +0 -0
  46. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/go_modules/workflow.py +0 -0
  47. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java/__init__.py +0 -0
  48. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java/actions.py +0 -0
  49. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java/utils.py +0 -0
  50. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/DESIGN.md +0 -0
  51. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/__init__.py +0 -0
  52. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/actions.py +0 -0
  53. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/gradle.py +0 -0
  54. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/gradle_resolver.py +0 -0
  55. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/gradle_validator.py +0 -0
  56. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle +0 -0
  57. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_gradle/workflow.py +0 -0
  58. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/DESIGN.md +0 -0
  59. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/__init__.py +0 -0
  60. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/actions.py +0 -0
  61. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/maven.py +0 -0
  62. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/maven_resolver.py +0 -0
  63. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/maven_validator.py +0 -0
  64. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/java_maven/workflow.py +0 -0
  65. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/DESIGN.md +0 -0
  66. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/__init__.py +0 -0
  67. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/actions.py +0 -0
  68. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/exceptions.py +0 -0
  69. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/lockfile_closure.py +0 -0
  70. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/npm.py +0 -0
  71. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/utils.py +0 -0
  72. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm/workflow.py +0 -0
  73. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/DESIGN.md +0 -0
  74. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/__init__.py +0 -0
  75. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/actions.py +0 -0
  76. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/esbuild.py +0 -0
  77. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/exceptions.py +0 -0
  78. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/workflow.py +0 -0
  79. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/DESIGN.md +0 -0
  80. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/__init__.py +0 -0
  81. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/actions.py +0 -0
  82. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/compat.py +0 -0
  83. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/exceptions.py +0 -0
  84. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/packager.py +0 -0
  85. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/utils.py +0 -0
  86. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/validator.py +0 -0
  87. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_pip/workflow.py +0 -0
  88. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/__init__.py +0 -0
  89. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/actions.py +0 -0
  90. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/python_uv/exceptions.py +0 -0
  91. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/ruby_bundler/DESIGN.md +0 -0
  92. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/ruby_bundler/__init__.py +0 -0
  93. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/ruby_bundler/actions.py +0 -0
  94. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/ruby_bundler/bundler.py +0 -0
  95. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/ruby_bundler/utils.py +0 -0
  96. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/ruby_bundler/workflow.py +0 -0
  97. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/DESIGN.md +0 -0
  98. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/__init__.py +0 -0
  99. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/actions.py +0 -0
  100. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py +0 -0
  101. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/exceptions.py +0 -0
  102. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/utils.py +0 -0
  103. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders/workflows/rust_cargo/workflow.py +0 -0
  104. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders.egg-info/SOURCES.txt +0 -0
  105. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders.egg-info/dependency_links.txt +0 -0
  106. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders.egg-info/entry_points.txt +0 -0
  107. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders.egg-info/requires.txt +0 -0
  108. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/aws_lambda_builders.egg-info/top_level.txt +0 -0
  109. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/pyproject.toml +0 -0
  110. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/requirements/base.txt +0 -0
  111. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/requirements/dev.txt +0 -0
  112. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/requirements/python_pip.txt +0 -0
  113. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/setup.cfg +0 -0
  114. {aws_lambda_builders-1.70.0 → aws_lambda_builders-1.71.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aws_lambda_builders
3
- Version: 1.70.0
3
+ Version: 1.71.0
4
4
  Summary: Python library to compile, build & package AWS Lambda functions for several runtimes & frameworks.
5
5
  Home-page: https://github.com/awslabs/aws-lambda-builders
6
6
  Author: Amazon Web Services
@@ -5,5 +5,5 @@ AWS Lambda Builder Library
5
5
  # Changing version will trigger a new release!
6
6
  # Please make the version change as the last step of your development.
7
7
 
8
- __version__ = "1.70.0"
8
+ __version__ = "1.71.0"
9
9
  RPC_PROTOCOL_VERSION = "0.3"
@@ -279,7 +279,10 @@ def extract_tarfile(tarfile_path: Union[str, os.PathLike], unpack_dir: Union[str
279
279
  if not _is_within_directory(unpack_dir, member_path):
280
280
  raise tarfile.ExtractError("Attempted Path Traversal in Tar File")
281
281
 
282
- tar.extractall(unpack_dir)
282
+ if hasattr(tarfile, "data_filter"):
283
+ tar.extractall(unpack_dir, filter="data")
284
+ else:
285
+ tar.extractall(unpack_dir)
283
286
 
284
287
 
285
288
  def _locale_encoding() -> str:
@@ -15,7 +15,7 @@ UV offers several advantages over pip:
15
15
 
16
16
  Similar to the Python PIP workflow, Python packaging for AWS Lambda presents unique challenges:
17
17
 
18
- 1. **Platform compatibility**: Python packages often contain platform-specific code or compiled extensions that must be compatible with the AWS Lambda runtime environment (Amazon Linux 2)
18
+ 1. **Platform compatibility**: Python packages often contain platform-specific code or compiled extensions that must be compatible with the AWS Lambda runtime environment (Amazon Linux 2 for Python 3.8-3.11, Amazon Linux 2023 for Python 3.12+)
19
19
 
20
20
  2. **Architecture compatibility**: Packages must be compatible with the target Lambda architecture (x86_64 or arm64)
21
21
 
@@ -64,7 +64,8 @@ def build_dependencies(artifacts_dir_path,
64
64
 
65
65
  :type runtime: str
66
66
  :param runtime: Python version to build dependencies for. This can
67
- be python3.8, python3.9, python3.10, python3.11, python3.12, or python3.13.
67
+ be python3.8, python3.9, python3.10, python3.11, python3.12, python3.13,
68
+ python3.14, or python3.15.
68
69
  These are currently the only supported values.
69
70
  Note: This parameter is passed to the PythonUvDependencyBuilder constructor.
70
71
 
@@ -104,22 +105,15 @@ builder.build_dependencies(
104
105
 
105
106
  The general algorithm for preparing a python package using UV for use on AWS Lambda follows a streamlined approach that leverages UV's advanced capabilities:
106
107
 
107
- #### Step 1: Smart manifest detection and dispatch
108
+ #### Step 1: Pick the manifest
108
109
 
109
- The workflow uses a smart dispatch system that recognizes actual manifest files:
110
+ An explicit manifest path is used as given. Without one, the workflow picks a manifest in the
111
+ order listed under [Smart Manifest Detection and Dispatch](#smart-manifest-detection-and-dispatch).
110
112
 
111
- **Supported Manifests:**
112
- - `pyproject.toml` - Modern Python project manifest
113
- - `requirements.txt` - Traditional pip requirements file
114
- - `requirements-*.txt` - Environment-specific variants (dev, prod, test, etc.)
115
-
116
- **Smart Lock File Detection:**
117
- - Look for requirements.txt first
118
- - When `pyproject.toml` is the manifest, resolves the workspace root (the project directory for standalone projects) and checks for `uv.lock` there
119
- - If `uv.lock` exists at that root, uses lock-based build for precise dependencies
120
- - If no `uv.lock`, uses standard pyproject.toml build with UV's lock and export workflow
121
-
122
- **Important:** `uv.lock` is NOT a standalone manifest - it's a lock file that enhances `pyproject.toml` builds when present.
113
+ When the manifest is `pyproject.toml`, the workflow resolves the workspace root (the project
114
+ directory for a standalone project; see
115
+ [Workspace Resolution Failure Policy](#workspace-resolution-failure-policy)) and uses a
116
+ `uv.lock` found there. `uv.lock` is never a manifest on its own.
123
117
 
124
118
  #### Step 2: Build dependencies based on manifest type
125
119
 
@@ -136,12 +130,26 @@ The workflow uses a smart dispatch system that recognizes actual manifest files:
136
130
  - Provides reproducible builds with locked dependency versions AND cross-platform support
137
131
 
138
132
  **For pyproject.toml without uv.lock:**
139
- - Use `uv lock` to create temporary lock file with resolved dependencies
133
+ - Run `uv lock` from the project directory. uv writes `uv.lock` there, or at the workspace root
134
+ for a workspace member, and the file stays in the source tree after the build
140
135
  - Use `uv export` to convert lock file to requirements.txt format
141
136
  - Install dependencies using `uv pip install` with platform targeting
142
137
 
138
+ **Stale locks:** both pyproject.toml paths run `uv export --locked`, so a `uv.lock` that no longer
139
+ matches `pyproject.toml` fails the build instead of being rewritten. A project without
140
+ `requires-python` that was locked on one Python version can be stale on another runtime; set
141
+ `requires-python` or run `uv lock` again.
142
+
143
+ **Hashes:** the export keeps the lock's hashes, so a project that sets `require-hashes` in
144
+ `[tool.uv.pip]` builds.
145
+
143
146
  **For requirements.txt files:**
144
147
  - Use `uv pip install` directly with Lambda-compatible settings
148
+ - uv runs from the manifest's directory, so local paths in the file (such as `./libs/foo` or
149
+ `-e ../shared`) resolve from there
150
+
151
+ **Local paths in lock builds:** exported local paths are relative to the workspace root, so
152
+ `uv pip install` runs from the workspace root (the project directory for a standalone project).
145
153
 
146
154
  **Why export + pip install instead of uv sync?**
147
155
  `uv sync` doesn't support cross-platform builds (no --python-platform flag). Since Lambda
@@ -214,7 +222,7 @@ config = {
214
222
  "no_cache": False, # Disable caching
215
223
  "prerelease": "disallow", # Handle pre-release versions
216
224
  "resolution": "highest", # Resolution strategy
217
- "compile_bytecode": True, # Compile .pyc files
225
+ "compile_bytecode": False, # Opt in to unchecked-hash .pyc compiled with the target Python
218
226
  "exclude_newer": None, # Exclude packages newer than date
219
227
  "generate_hashes": False, # Generate package hashes
220
228
  }
@@ -231,6 +239,7 @@ SAM CLI maps them from `Metadata.BuildProperties`.
231
239
  | `uv_extras` | `UvExtras` | list of str | `--extra <name>` per entry |
232
240
  | `uv_all_extras` | `UvAllExtras` | bool | `--all-extras` |
233
241
  | `uv_prune` | `UvPrune` | list of str | `--prune <name>` per entry: drops the package and any dependency only it needs |
242
+ | `uv_compile_bytecode` | `UvCompileBytecode` | bool | none; after install, runs `compileall --invalidation-mode unchecked-hash` with the target Python (also for `requirements.txt` builds) |
234
243
 
235
244
  Default groups stay excluded (`--no-default-groups`); `uv_groups` adds groups on top of that.
236
245
  `uv_prune` is meant for packages the Lambda runtime already ships, such as `boto3`. The function then
@@ -238,21 +247,45 @@ uses the runtime's version, which AWS picks, not the version in `uv.lock`.
238
247
  The build fails with a clear message, instead of ignoring the option, when:
239
248
  - a value has the wrong type, or an unknown `uv_*` key is given;
240
249
  - `uv_extras` and `uv_all_extras` are combined;
241
- - an option is set on a `requirements.txt` build (they apply only to pyproject.toml / uv.lock projects);
250
+ - an option other than `uv_compile_bytecode` is set on a `requirements.txt` build (they apply only to
251
+ pyproject.toml / uv.lock projects);
242
252
  - a `uv_prune` name is not a package in `uv.lock`, which `uv export --prune` would otherwise ignore.
243
253
 
254
+ ### Bytecode
255
+
256
+ uv writes timestamp-based `.pyc` files, which the Lambda runtime rejects once SAM normalizes file
257
+ timestamps in the deployment package. So the workflow always passes `--no-compile-bytecode` to
258
+ `uv pip install`, removes `UV_COMPILE_BYTECODE` from that command's environment (uv refuses the flag and
259
+ the variable together), and, when bytecode is enabled, runs the target Python
260
+ (`uv python find --no-project --no-python-downloads <version>`) as
261
+ `python -m compileall -f -q --invalidation-mode unchecked-hash` over the install directory.
262
+
263
+ Bytecode is enabled by `uv_compile_bytecode: true`. When that option isn't given, a truthy
264
+ `UV_COMPILE_BYTECODE` in the build environment enables it too, and the build logs that at INFO. Values are
265
+ read the way uv reads them, case-insensitively: `1`, `true`, `t`, `yes`, `y`, `on` enable it; `0`, `false`,
266
+ `f`, `no`, `n`, `off` leave it off; any other value logs a warning and leaves it off. An explicit
267
+ `uv_compile_bytecode: false` always wins over the variable. If the target Python isn't installed, or the
268
+ runtime gives no version, the build logs a warning and ships no bytecode instead of failing.
269
+
244
270
  ### Settings from pyproject.toml
245
271
 
246
272
  The workflow runs `uv export` and `uv pip install` from the project, so uv reads its own settings there.
247
273
  Build-control settings in `[tool.uv]` (`no-build`, `no-build-package`, `no-binary`, `no-binary-package`) apply
248
274
  to both steps; `[tool.uv.pip]` settings (`no-build`, `no-binary`, `only-binary`) apply to the install. `UV_*`
249
- environment variables apply to every uv call. The workflow's own flags always win: the target platform and
275
+ environment variables apply to every uv call, except `UV_COMPILE_BYTECODE` (see Bytecode). The workflow's own flags always win: the target platform and
250
276
  Python version come from the function's architecture and runtime, default groups are excluded, and nothing
251
277
  is installed editable. In a uv workspace only the workspace root's `pyproject.toml` settings are used; a
252
278
  member's `[tool.uv]` and `[tool.uv.pip]` tables are ignored. An unknown key in either table makes uv ignore
253
279
  every setting in that file. The build log shows uv's warning about it (the workflow logs every `warning:`
254
280
  that uv prints, once per build), so check the key names against uv's settings reference.
255
281
 
282
+ ### uv warnings
283
+
284
+ Every `warning:` block uv prints is logged at WARNING, once per build. Some are harmless, such as
285
+ "Failed to hardlink files; falling back to full copy" when the cache and the target are on
286
+ different file systems. The one to act on is an unknown key in `[tool.uv]` (or `[tool.uv.pip]`):
287
+ uv then ignores every setting in that file.
288
+
256
289
  ### Caching
257
290
 
258
291
  The workflow does not pass `--cache-dir` unless a caller supplies one, so UV uses its own
@@ -291,7 +324,7 @@ The UV workflow consists of several key components that mirror the PIP workflow
291
324
  2. **PythonUvBuildAction**: Action class that handles dependency resolution
292
325
  3. **UvRunner**: Wrapper around UV command execution
293
326
  4. **SubprocessUv**: Low-level UV subprocess interface
294
- 6. **PythonUvDependencyBuilder**: High-level dependency builder orchestrator
327
+ 5. **PythonUvDependencyBuilder**: High-level dependency builder orchestrator
295
328
 
296
329
  #### File Structure
297
330
  ```
@@ -342,12 +375,16 @@ The workflow follows Python ecosystem standards for requirements files:
342
375
  - `requirements-prod.txt` - Production dependencies
343
376
  - `requirements-staging.txt` - Staging dependencies
344
377
 
378
+ Only `requirements.txt` and `requirements-prod.txt` are auto-detected. The others are used only
379
+ when passed as the manifest path.
380
+
345
381
  Note: `requirements.in` (pip-tools format) is not supported to keep the implementation simple and focused.
346
382
 
347
383
  #### UV Binary Requirements
348
384
  - UV must be available on the system PATH
349
385
  - Minimum UV version: 0.1.0 (to be determined based on feature requirements)
350
- - Fallback: Attempt to install UV using pip if not found (optional behavior)
386
+ - Workspace discovery needs UV 0.9.9 or newer; older versions build from the project directory
387
+ - A missing UV raises `MissingUvError`; the workflow does not install UV
351
388
 
352
389
  #### Error Handling Strategy
353
390
  - **MissingUvError**: UV binary not found on PATH (includes path information)
@@ -397,7 +434,8 @@ instead of recommending an upgrade for an unknown cause.
397
434
  | python3.11 | ✓ | ✓ | Supported |
398
435
  | python3.12 | ✓ | ✓ | Supported |
399
436
  | python3.13 | ✓ | ✓ | Supported |
400
- | python3.13 | ✓ | ✓ | Supported |
437
+ | python3.14 | ✓ | ✓ | Supported |
438
+ | python3.15 | ✓ | ✓ | Supported |
401
439
 
402
440
  #### Integration with Lambda Builders
403
441
  - Registers with the workflow registry automatically
@@ -11,7 +11,7 @@ from typing import Dict, List, Optional, Set
11
11
  from aws_lambda_builders.architecture import ARM64, X86_64
12
12
 
13
13
  from .exceptions import LockFileError, MissingUvError, UvBuildError, UvInstallationError
14
- from .utils import OSUtils, UvConfig
14
+ from .utils import OSUtils, UvConfig, normalize_package_name
15
15
 
16
16
  LOG = logging.getLogger(__name__)
17
17
 
@@ -57,6 +57,17 @@ class SubprocessUv:
57
57
  pass
58
58
  return None
59
59
 
60
+ def find_python(self, python_version: str) -> Optional[str]:
61
+ """Find an already-installed interpreter matching the requested Python version."""
62
+ rc, stdout, stderr = self.run_uv_command(
63
+ ["python", "find", "--no-project", "--no-python-downloads", python_version]
64
+ )
65
+ if rc == 0 and stdout:
66
+ return stdout.strip()
67
+ diagnostic = (stderr or "").strip() or (stdout or "").strip() or "no diagnostic output"
68
+ LOG.warning("Could not locate target Python %s via uv (exit code %d): %s", python_version, rc, diagnostic)
69
+ return None
70
+
60
71
  def run_uv_command(self, args: List[str], cwd: Optional[str] = None, env: Optional[Dict[str, str]] = None) -> tuple:
61
72
  """
62
73
  Execute UV command with given arguments.
@@ -165,15 +176,33 @@ class UvRunner:
165
176
  # Resolve --target to an absolute path: UV runs from the project or workspace directory,
166
177
  # so a relative target (e.g. the incremental-build dependencies dir) would otherwise be
167
178
  # created under the UV's cwd instead of the build root.
168
- args.extend(["--target", os.path.abspath(target_dir)])
179
+ target_dir = os.path.abspath(target_dir)
180
+ args.extend(["--target", target_dir])
169
181
 
170
- # Add configuration arguments
182
+ target_python = None
183
+ if config.compile_bytecode:
184
+ if python_version:
185
+ target_python = self._uv.find_python(python_version)
186
+ else:
187
+ LOG.warning("Target Python version is unavailable; skipping bytecode compilation")
188
+
189
+ # Add configuration arguments that are independent of interpreter selection.
171
190
  args.extend(config.to_uv_args())
172
191
 
173
192
  # Add platform-specific arguments
174
193
  if python_version:
175
194
  args.extend(["--python-version", python_version])
176
195
 
196
+ # Use the exact interpreter found by UV instead of repeating a version request that
197
+ # could resolve differently when the install command runs.
198
+ if target_python:
199
+ args.extend(["--python", target_python])
200
+
201
+ # UV currently produces timestamp-based bytecode. SAM packages files with normalized
202
+ # timestamps, so that bytecode would be rejected by the Lambda runtime after deployment.
203
+ # Keep UV compilation disabled and generate unchecked-hash bytecode below instead.
204
+ args.append("--no-compile-bytecode")
205
+
177
206
  if platform and architecture:
178
207
  # UV pip install uses --python-platform format
179
208
  # Map Lambda architectures to UV platform strings
@@ -193,14 +222,47 @@ class UvRunner:
193
222
  python_platform = f"{target_arch}-manylinux_{manylinux_version}"
194
223
  args.extend(["--python-platform", python_platform])
195
224
 
225
+ # uv rejects --no-compile-bytecode when UV_COMPILE_BYTECODE is also set ("cannot be used
226
+ # with"), so drop the variable for this command; bytecode is handled by _compile_bytecode.
227
+ env = self._osutils.original_environ()
228
+ env.pop("UV_COMPILE_BYTECODE", None)
229
+
196
230
  # Execute UV pip install
197
- rc, stdout, stderr = self._uv.run_uv_command(args, cwd)
231
+ rc, stdout, stderr = self._uv.run_uv_command(args, cwd, env=env)
198
232
 
199
233
  if rc != 0:
200
234
  raise UvInstallationError(reason=f"UV pip install failed: {stderr}")
201
235
 
202
236
  LOG.debug("UV pip install completed successfully: %s", stdout)
203
237
 
238
+ if target_python:
239
+ self._compile_bytecode(target_python, target_dir)
240
+
241
+ def _compile_bytecode(self, python_executable: str, target_dir: str) -> None:
242
+ """Compile reusable bytecode with the interpreter selected for the target runtime."""
243
+ command = [
244
+ python_executable,
245
+ "-m",
246
+ "compileall",
247
+ "-f",
248
+ "-q",
249
+ "--invalidation-mode",
250
+ "unchecked-hash",
251
+ target_dir,
252
+ ]
253
+ LOG.debug("Compiling unchecked-hash bytecode: %s", " ".join(command))
254
+ rc, stdout, stderr = self._osutils.run_subprocess(command)
255
+ if rc != 0:
256
+ diagnostic = stderr.strip() or stdout.strip() or "no diagnostic output"
257
+ LOG.warning(
258
+ "Could not compile unchecked-hash bytecode with target Python (exit code %d): %s",
259
+ rc,
260
+ diagnostic,
261
+ )
262
+ return
263
+
264
+ LOG.debug("Python bytecode compilation completed successfully: %s", stdout)
265
+
204
266
 
205
267
  class PythonUvDependencyBuilder:
206
268
  """High-level dependency builder that orchestrates UV operations."""
@@ -499,7 +561,7 @@ class PythonUvDependencyBuilder:
499
561
  return
500
562
 
501
563
  locked = {package.get("name") for package in packages if isinstance(package, dict)}
502
- missing = [name for name in prune if re.sub(r"[-_.]+", "-", name).lower() not in locked]
564
+ missing = [name for name in prune if normalize_package_name(name) not in locked]
503
565
  if missing:
504
566
  raise LockFileError(reason=f"Build option uv_prune names packages not in {lock_path}: {', '.join(missing)}")
505
567
 
@@ -4,6 +4,7 @@ Commonly used utilities for Python UV workflow
4
4
 
5
5
  import logging
6
6
  import os
7
+ import re
7
8
  import shutil
8
9
  import subprocess
9
10
  from typing import List, Optional
@@ -15,6 +16,11 @@ LOG = logging.getLogger(__name__)
15
16
  EXPERIMENTAL_FLAG_BUILD_PERFORMANCE = "experimentalBuildPerformance"
16
17
 
17
18
 
19
+ def normalize_package_name(name: str) -> str:
20
+ """PEP 503 normalized name, the form uv.lock stores package names in."""
21
+ return re.sub(r"[-_.]+", "-", name).lower()
22
+
23
+
18
24
  class OSUtils(BaseOSUtils):
19
25
  """Extended OS utilities for UV workflow."""
20
26
 
@@ -28,7 +34,16 @@ class OSUtils(BaseOSUtils):
28
34
  env = self.original_environ()
29
35
 
30
36
  try:
31
- result = subprocess.run(cmd, cwd=cwd, env=env, capture_output=True, text=True, check=False)
37
+ result = subprocess.run(
38
+ cmd,
39
+ cwd=cwd,
40
+ env=env,
41
+ capture_output=True,
42
+ text=True,
43
+ encoding="utf-8",
44
+ errors="replace",
45
+ check=False,
46
+ )
32
47
  return result.returncode, result.stdout, result.stderr
33
48
  except Exception as e:
34
49
  return 1, "", str(e)
@@ -133,7 +148,7 @@ class UvConfig:
133
148
  no_cache: bool = False,
134
149
  prerelease: str = "disallow",
135
150
  resolution: str = "highest",
136
- compile_bytecode: bool = True,
151
+ compile_bytecode: bool = False,
137
152
  exclude_newer: Optional[str] = None,
138
153
  generate_hashes: bool = False,
139
154
  groups: Optional[List[str]] = None,
@@ -10,7 +10,7 @@ from aws_lambda_builders.exceptions import WorkflowFailedError
10
10
  from aws_lambda_builders.workflow import BaseWorkflow, BuildDirectory, BuildInSourceSupport, Capability
11
11
 
12
12
  from .actions import PythonUvBuildAction
13
- from .utils import OSUtils, UvConfig, detect_uv_manifest
13
+ from .utils import OSUtils, UvConfig, detect_uv_manifest, normalize_package_name
14
14
 
15
15
  LOG = logging.getLogger(__name__)
16
16
 
@@ -20,8 +20,29 @@ UV_OPTIONS = {
20
20
  "uv_extras": list,
21
21
  "uv_all_extras": bool,
22
22
  "uv_prune": list,
23
+ "uv_compile_bytecode": bool,
23
24
  }
24
25
 
26
+ # Values uv accepts for UV_COMPILE_BYTECODE (clap's boolish parser, case-insensitive)
27
+ UV_ENV_TRUE = ("1", "true", "t", "yes", "y", "on")
28
+ UV_ENV_FALSE = ("0", "false", "f", "no", "n", "off")
29
+
30
+
31
+ def _compile_bytecode_from_env():
32
+ """Honor UV_COMPILE_BYTECODE when the uv_compile_bytecode build option isn't given.
33
+
34
+ The builder drops the variable from `uv pip install` (it conflicts with --no-compile-bytecode),
35
+ so read the user's intent here and compile unchecked-hash bytecode instead.
36
+ """
37
+ value = os.environ.get("UV_COMPILE_BYTECODE")
38
+ if value is None or value.lower() in UV_ENV_FALSE:
39
+ return False
40
+ if value.lower() in UV_ENV_TRUE:
41
+ LOG.info("UV_COMPILE_BYTECODE=%s is set, compiling unchecked-hash bytecode for dependencies", value)
42
+ return True
43
+ LOG.warning("Ignoring UV_COMPILE_BYTECODE=%r: expected one of %s", value, ", ".join(UV_ENV_TRUE + UV_ENV_FALSE))
44
+ return False
45
+
25
46
 
26
47
  class PythonUvWorkflow(BaseWorkflow):
27
48
  """
@@ -141,22 +162,53 @@ class PythonUvWorkflow(BaseWorkflow):
141
162
  if values.get("uv_all_extras") and values.get("uv_extras"):
142
163
  self._fail("Build options uv_extras and uv_all_extras cannot be used together")
143
164
 
165
+ # An explicit uv_compile_bytecode (true or false) wins over the environment
166
+ if "uv_compile_bytecode" not in values:
167
+ values["uv_compile_bytecode"] = _compile_bytecode_from_env()
168
+
144
169
  if not any(values.values()):
145
170
  return UvConfig()
146
171
 
147
- if not manifest_path or os.path.basename(manifest_path) != "pyproject.toml":
172
+ # Bytecode is compiled after install, so it works for every manifest type;
173
+ # the other options shape `uv export` and need a pyproject.toml project.
174
+ export_options = {key: value for key, value in values.items() if key != "uv_compile_bytecode" and value}
175
+ if export_options and (not manifest_path or os.path.basename(manifest_path) != "pyproject.toml"):
148
176
  self._fail(
149
- f"Build options {', '.join(sorted(values))} need a pyproject.toml project, "
177
+ f"Build options {', '.join(sorted(export_options))} need a pyproject.toml project, "
150
178
  f"but this build uses {os.path.basename(manifest_path) if manifest_path else 'no manifest'}"
151
179
  )
152
180
 
181
+ # Only uv_prune needs the project name, and it's only set here with a pyproject.toml manifest
182
+ project_name = self._project_name(manifest_path) if values.get("uv_prune") else None
183
+ if project_name and any(
184
+ normalize_package_name(name) == normalize_package_name(project_name) for name in values["uv_prune"]
185
+ ):
186
+ self._fail(f"Build option uv_prune cannot name the project being built ({project_name})")
187
+
153
188
  return UvConfig(
154
189
  groups=values.get("uv_groups"),
155
190
  extras=values.get("uv_extras"),
156
191
  all_extras=values.get("uv_all_extras", False),
157
192
  prune=values.get("uv_prune"),
193
+ compile_bytecode=values.get("uv_compile_bytecode", False),
158
194
  )
159
195
 
196
+ @staticmethod
197
+ def _project_name(pyproject_path):
198
+ """[project].name of the function's own pyproject.toml, or None if it has none."""
199
+ try:
200
+ import tomllib
201
+ except ModuleNotFoundError: # Python 3.10
202
+ import tomli as tomllib
203
+
204
+ try:
205
+ with open(pyproject_path, "rb") as pyproject_file:
206
+ project = tomllib.load(pyproject_file).get("project")
207
+ except (OSError, ValueError): # Leave unreadable manifests to uv's own diagnostics
208
+ return None
209
+ name = project.get("name") if isinstance(project, dict) else None
210
+ return name if isinstance(name, str) else None
211
+
160
212
  def _setup_build_actions(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtime, config=None):
161
213
  """
162
214
  Set up the build actions based on configuration.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aws_lambda_builders
3
- Version: 1.70.0
3
+ Version: 1.71.0
4
4
  Summary: Python library to compile, build & package AWS Lambda functions for several runtimes & frameworks.
5
5
  Home-page: https://github.com/awslabs/aws-lambda-builders
6
6
  Author: Amazon Web Services