aws-lambda-builders 1.68.0__tar.gz → 1.70.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 (115) hide show
  1. {aws_lambda_builders-1.68.0/aws_lambda_builders.egg-info → aws_lambda_builders-1.70.0}/PKG-INFO +5 -2
  2. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/__init__.py +1 -1
  3. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/actions.py +50 -1
  4. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/supported_runtimes.py +2 -0
  5. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/utils.py +80 -5
  6. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/DESIGN.md +1 -1
  7. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/packager.py +3 -1
  8. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/workflow.py +10 -2
  9. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/DESIGN.md +92 -8
  10. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/actions.py +2 -2
  11. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/packager.py +272 -24
  12. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/utils.py +74 -19
  13. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/workflow.py +55 -3
  14. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0/aws_lambda_builders.egg-info}/PKG-INFO +5 -2
  15. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders.egg-info/requires.txt +7 -1
  16. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/pyproject.toml +1 -1
  17. aws_lambda_builders-1.70.0/requirements/base.txt +1 -0
  18. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/requirements/dev.txt +2 -1
  19. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/setup.py +1 -0
  20. aws_lambda_builders-1.68.0/requirements/base.txt +0 -1
  21. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/LICENSE +0 -0
  22. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/MANIFEST.in +0 -0
  23. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/NOTICE +0 -0
  24. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/README.md +0 -0
  25. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/__main__.py +0 -0
  26. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/architecture.py +0 -0
  27. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/binary_path.py +0 -0
  28. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/builder.py +0 -0
  29. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/exceptions.py +0 -0
  30. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/path_resolver.py +0 -0
  31. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/registry.py +0 -0
  32. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/validator.py +0 -0
  33. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflow.py +0 -0
  34. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/__init__.py +0 -0
  35. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/DESIGN.md +0 -0
  36. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/__init__.py +0 -0
  37. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/actions.py +0 -0
  38. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/exceptions.py +0 -0
  39. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/make.py +0 -0
  40. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/utils.py +0 -0
  41. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/validator.py +0 -0
  42. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/custom_make/workflow.py +0 -0
  43. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/DESIGN.md +0 -0
  44. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/__init__.py +0 -0
  45. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/actions.py +0 -0
  46. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli.py +0 -0
  47. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli_resolver.py +0 -0
  48. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/utils.py +0 -0
  49. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/dotnet_clipackage/workflow.py +0 -0
  50. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/DESIGN.md +0 -0
  51. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/__init__.py +0 -0
  52. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/actions.py +0 -0
  53. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/builder.py +0 -0
  54. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/utils.py +0 -0
  55. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/validator.py +0 -0
  56. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/go_modules/workflow.py +0 -0
  57. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java/__init__.py +0 -0
  58. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java/actions.py +0 -0
  59. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java/utils.py +0 -0
  60. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/DESIGN.md +0 -0
  61. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/__init__.py +0 -0
  62. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/actions.py +0 -0
  63. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/gradle.py +0 -0
  64. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/gradle_resolver.py +0 -0
  65. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/gradle_validator.py +0 -0
  66. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle +0 -0
  67. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_gradle/workflow.py +0 -0
  68. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/DESIGN.md +0 -0
  69. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/__init__.py +0 -0
  70. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/actions.py +0 -0
  71. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/maven.py +0 -0
  72. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/maven_resolver.py +0 -0
  73. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/maven_validator.py +0 -0
  74. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/java_maven/workflow.py +0 -0
  75. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/DESIGN.md +0 -0
  76. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/__init__.py +0 -0
  77. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/actions.py +0 -0
  78. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/exceptions.py +0 -0
  79. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/lockfile_closure.py +0 -0
  80. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/npm.py +0 -0
  81. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/utils.py +0 -0
  82. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm/workflow.py +0 -0
  83. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/DESIGN.md +0 -0
  84. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/__init__.py +0 -0
  85. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/actions.py +0 -0
  86. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/esbuild.py +0 -0
  87. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/exceptions.py +0 -0
  88. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/nodejs_npm_esbuild/workflow.py +0 -0
  89. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/__init__.py +0 -0
  90. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/actions.py +0 -0
  91. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/compat.py +0 -0
  92. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/exceptions.py +0 -0
  93. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/utils.py +0 -0
  94. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_pip/validator.py +0 -0
  95. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/__init__.py +0 -0
  96. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/python_uv/exceptions.py +0 -0
  97. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/ruby_bundler/DESIGN.md +0 -0
  98. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/ruby_bundler/__init__.py +0 -0
  99. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/ruby_bundler/actions.py +0 -0
  100. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/ruby_bundler/bundler.py +0 -0
  101. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/ruby_bundler/utils.py +0 -0
  102. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/ruby_bundler/workflow.py +0 -0
  103. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/DESIGN.md +0 -0
  104. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/__init__.py +0 -0
  105. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/actions.py +0 -0
  106. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py +0 -0
  107. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/exceptions.py +0 -0
  108. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/utils.py +0 -0
  109. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders/workflows/rust_cargo/workflow.py +0 -0
  110. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders.egg-info/SOURCES.txt +0 -0
  111. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders.egg-info/dependency_links.txt +0 -0
  112. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders.egg-info/entry_points.txt +0 -0
  113. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/aws_lambda_builders.egg-info/top_level.txt +0 -0
  114. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/requirements/python_pip.txt +0 -0
  115. {aws_lambda_builders-1.68.0 → aws_lambda_builders-1.70.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aws_lambda_builders
3
- Version: 1.68.0
3
+ Version: 1.70.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
@@ -20,22 +20,25 @@ Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: 3.15
23
24
  Classifier: Topic :: Internet
24
25
  Classifier: Topic :: Software Development :: Build Tools
25
26
  Classifier: Topic :: Utilities
26
27
  Requires-Python: >=3.10
27
28
  License-File: LICENSE
28
29
  License-File: NOTICE
30
+ Requires-Dist: tomli>=1.1.0; python_version < "3.11"
29
31
  Requires-Dist: setuptools
30
32
  Requires-Dist: wheel
31
33
  Provides-Extra: dev
32
34
  Requires-Dist: coverage==7.15.1; extra == "dev"
33
35
  Requires-Dist: flake8==3.8.4; extra == "dev"
34
36
  Requires-Dist: pytest-cov==6.3.0; extra == "dev"
37
+ Requires-Dist: tomli>=1.1.0; python_version < "3.11" and extra == "dev"
35
38
  Requires-Dist: pytest>=9.1.1; extra == "dev"
36
39
  Requires-Dist: parameterized==0.9.0; extra == "dev"
37
40
  Requires-Dist: pyelftools~=0.33; extra == "dev"
38
- Requires-Dist: black==26.5.1; extra == "dev"
41
+ Requires-Dist: black==26.10.1; extra == "dev"
39
42
  Requires-Dist: ruff==0.16.5; extra == "dev"
40
43
  Dynamic: author
41
44
  Dynamic: author-email
@@ -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.68.0"
8
+ __version__ = "1.70.0"
9
9
  RPC_PROTOCOL_VERSION = "0.3"
@@ -132,17 +132,66 @@ class LinkSourceAction(BaseAction):
132
132
  self._dest_dir = dest_dir
133
133
 
134
134
  def execute(self):
135
+ # Match CopySourceAction: a missing source is skipped, not fatal.
136
+ if not os.path.isdir(self._source_dir):
137
+ LOG.warning("Skipping link operation since source %s does not exist", self._source_dir)
138
+ return
139
+
135
140
  source_files = set(os.listdir(self._source_dir))
136
141
 
137
142
  for source_file in source_files:
138
143
  source_path = Path(self._source_dir, source_file)
139
144
  destination_path = Path(self._dest_dir, source_file)
140
- if destination_path.exists():
145
+ # is_symlink() first: a dangling link is not exists().
146
+ if destination_path.is_symlink() or destination_path.is_file():
141
147
  os.remove(destination_path)
148
+ elif destination_path.is_dir():
149
+ # Left by an earlier copying build.
150
+ shutil.rmtree(destination_path)
142
151
  else:
143
152
  os.makedirs(destination_path.parent, exist_ok=True)
144
153
  utils.create_symlink_or_copy(str(source_path), str(destination_path))
145
154
 
155
+ self._prune_dangling_links(source_files)
156
+
157
+ def _prune_dangling_links(self, source_files):
158
+ """
159
+ Remove broken links into the source directory whose source no longer exists.
160
+
161
+ :type source_files: set
162
+ :param source_files: names currently in the source directory
163
+ """
164
+ if not os.path.isdir(self._dest_dir):
165
+ return
166
+
167
+ for name in set(os.listdir(self._dest_dir)) - source_files:
168
+ stale_path = Path(self._dest_dir, name)
169
+ if not stale_path.is_symlink() or stale_path.exists():
170
+ continue
171
+ if not self._points_into_source(stale_path):
172
+ continue
173
+ LOG.debug("Removing %s: a link to a source that no longer exists", stale_path)
174
+ os.remove(stale_path)
175
+
176
+ def _points_into_source(self, link_path):
177
+ """
178
+ Return True if the link targets a direct child of the source directory.
179
+
180
+ Uses os.readlink, not os.path.realpath, which does not follow a broken link on Windows.
181
+
182
+ :type link_path: pathlib.Path
183
+ :param link_path: the symlink to check
184
+ :rtype: bool
185
+ """
186
+ target = os.readlink(link_path)
187
+ if not os.path.isabs(target):
188
+ target = os.path.join(os.path.dirname(link_path), target)
189
+
190
+ target_parent = os.path.dirname(os.path.normpath(target))
191
+ if not os.path.isdir(target_parent):
192
+ return False
193
+ return os.path.samefile(target_parent, self._source_dir)
194
+
146
195
 
147
196
  class LinkSinglePathAction(BaseAction):
148
197
  NAME = "LinkSource"
@@ -14,6 +14,7 @@ NODEJS_RUNTIMES = [
14
14
  "nodejs20.x",
15
15
  "nodejs22.x",
16
16
  "nodejs24.x",
17
+ "nodejs26.x",
17
18
  ]
18
19
 
19
20
  # Python runtimes
@@ -25,6 +26,7 @@ PYTHON_RUNTIMES = [
25
26
  "python3.12",
26
27
  "python3.13",
27
28
  "python3.14",
29
+ "python3.15",
28
30
  ]
29
31
 
30
32
  # Ruby runtimes
@@ -2,6 +2,7 @@
2
2
  Common utilities for the library
3
3
  """
4
4
 
5
+ import codecs
5
6
  import locale
6
7
  import logging
7
8
  import os
@@ -15,6 +16,28 @@ from aws_lambda_builders.architecture import ARM64
15
16
  LOG = logging.getLogger(__name__)
16
17
 
17
18
 
19
+ def _materialize_symlinked_destination(destination: str) -> None:
20
+ """
21
+ Replace a symlinked destination with a real copy of its target, so copying into it
22
+ does not write into the shared dependencies directory.
23
+
24
+ :type destination: str
25
+ :param destination: path that may be a symlink
26
+ """
27
+ if not os.path.islink(destination):
28
+ return
29
+
30
+ LOG.debug("Replacing symlinked destination %s with a real copy before copying into it", destination)
31
+ link_target = os.path.realpath(destination)
32
+ os.unlink(destination)
33
+
34
+ if os.path.isdir(link_target):
35
+ copytree(link_target, destination)
36
+ elif os.path.isfile(link_target):
37
+ os.makedirs(os.path.dirname(destination), exist_ok=True)
38
+ shutil.copy2(link_target, destination)
39
+
40
+
18
41
  def copytree(
19
42
  source: str,
20
43
  destination: str,
@@ -48,6 +71,8 @@ def copytree(
48
71
  LOG.warning("Skipping copy operation since source %s does not exist", source)
49
72
  return
50
73
 
74
+ _materialize_symlinked_destination(destination)
75
+
51
76
  if not os.path.exists(destination):
52
77
  LOG.debug("Creating target folders at %s", destination)
53
78
  os.makedirs(destination)
@@ -86,6 +111,9 @@ def copytree(
86
111
  elif os.path.isdir(new_source):
87
112
  copytree(new_source, new_destination, ignore=ignore, include=include, maintain_symlinks=maintain_symlinks)
88
113
  else:
114
+ # copy2 would write through a symlinked destination.
115
+ if os.path.islink(new_destination):
116
+ os.unlink(new_destination)
89
117
  LOG.debug("Copying source file (%s) to destination (%s)", new_source, new_destination)
90
118
  shutil.copy2(new_source, new_destination)
91
119
 
@@ -210,7 +238,19 @@ def create_symlink_or_copy(source: str, destination: str) -> None:
210
238
  "consider enabling the necessary settings or privileges on your system to support symbolic links.",
211
239
  exc_info=ex if LOG.isEnabledFor(logging.DEBUG) else None,
212
240
  )
213
- copytree(source, destination)
241
+ # A broken link at the destination is one reason os.symlink fails. Remove it so the copy
242
+ # below doesn't write through it.
243
+ if os.path.islink(destination):
244
+ LOG.debug("Removing existing symlink at destination %s before copying", destination)
245
+ os.unlink(destination)
246
+ # copytree only handles directories; a dependency can also be a single file (six.py).
247
+ if os.path.isdir(source):
248
+ copytree(source, destination)
249
+ elif os.path.isfile(source):
250
+ os.makedirs(os.path.dirname(destination), exist_ok=True)
251
+ shutil.copy2(source, destination)
252
+ else:
253
+ LOG.warning("Skipping copy operation since source %s does not exist", source)
214
254
 
215
255
 
216
256
  def _is_within_directory(directory: Union[str, os.PathLike], target: Union[str, os.PathLike]) -> bool:
@@ -218,9 +258,13 @@ def _is_within_directory(directory: Union[str, os.PathLike], target: Union[str,
218
258
  abs_directory = os.path.abspath(directory)
219
259
  abs_target = os.path.abspath(target)
220
260
 
221
- prefix = os.path.commonprefix([abs_directory, abs_target])
222
-
223
- return prefix == abs_directory
261
+ try:
262
+ # commonpath compares whole path components; commonprefix compares characters,
263
+ # which would wrongly treat "/tmp/ab/x" as being inside "/tmp/a".
264
+ return os.path.commonpath([abs_directory, abs_target]) == abs_directory
265
+ except ValueError:
266
+ # Raised for paths on different drives (Windows): they cannot be nested
267
+ return False
224
268
 
225
269
 
226
270
  def extract_tarfile(tarfile_path: Union[str, os.PathLike], unpack_dir: Union[str, os.PathLike]) -> None:
@@ -238,6 +282,37 @@ def extract_tarfile(tarfile_path: Union[str, os.PathLike], unpack_dir: Union[str
238
282
  tar.extractall(unpack_dir)
239
283
 
240
284
 
285
+ def _locale_encoding() -> str:
286
+ """
287
+ Returns the encoding to decode the output of external tools (pip, npm, maven, ...) with.
288
+
289
+ Before Python 3.15, ``locale.getpreferredencoding()`` returned the locale encoding, or "utf-8" when
290
+ UTF-8 mode was enabled (explicitly, or automatically for the C/POSIX locale, PEP 540). Python 3.15
291
+ enables UTF-8 mode by default (PEP 686), so ``getpreferredencoding()`` now returns "utf-8" even for
292
+ non-UTF-8 locales such as a Windows ANSI code page, while external tools still write in that encoding.
293
+ This keeps the pre-3.15 behaviour:
294
+
295
+ - UTF-8 mode explicitly requested (PYTHONUTF8=1 or -X utf8): utf-8
296
+ - otherwise the locale encoding (``locale.getencoding()``, Python 3.11+), except that an ASCII locale
297
+ (C/POSIX) is decoded as utf-8, a superset of ASCII
298
+ """
299
+ getencoding = getattr(locale, "getencoding", None)
300
+ if getencoding is None:
301
+ # Python < 3.11: UTF-8 mode is never on by default, so this is the historical behaviour
302
+ return locale.getpreferredencoding()
303
+
304
+ if os.environ.get("PYTHONUTF8") == "1" or sys._xoptions.get("utf8") in (True, "1"):
305
+ return "utf-8"
306
+
307
+ encoding = getencoding()
308
+ try:
309
+ if codecs.lookup(encoding).name == "ascii":
310
+ return "utf-8"
311
+ except LookupError:
312
+ return "utf-8"
313
+ return encoding
314
+
315
+
241
316
  def decode(to_decode: bytes, encoding: Optional[str] = None) -> str:
242
317
  """
243
318
  Perform a "safe" decoding of a series of bytes. Attempts to find the localized encoding
@@ -258,5 +333,5 @@ def decode(to_decode: bytes, encoding: Optional[str] = None) -> str:
258
333
  str
259
334
  Decoded string with unrecognized characters replaced with a replacement character
260
335
  """
261
- encoding = encoding or locale.getpreferredencoding()
336
+ encoding = encoding or _locale_encoding()
262
337
  return to_decode.decode(encoding, errors="replace").strip()
@@ -49,7 +49,7 @@ def build_dependencies(artifacts_dir_path,
49
49
 
50
50
  :type runtime: str
51
51
  :param runtime: Python version to build dependencies for. This can
52
- either be python3.8, python3.9, python3.10, python3.11, python3.12, python3.13 or python3.14. These are
52
+ either be python3.8, python3.9, python3.10, python3.11, python3.12, python3.13, python3.14 or python3.15. These are
53
53
  currently the only supported values.
54
54
 
55
55
  :type ui: :class:`lambda_builders.actions.python_pip.utils.UI`
@@ -89,6 +89,7 @@ def get_lambda_abi(runtime):
89
89
  "python3.12": "cp312",
90
90
  "python3.13": "cp313",
91
91
  "python3.14": "cp314",
92
+ "python3.15": "cp315",
92
93
  }
93
94
 
94
95
  if runtime not in supported:
@@ -103,7 +104,7 @@ class PythonPipDependencyBuilder(object):
103
104
 
104
105
  :type runtime: str
105
106
  :param runtime: Python version to build dependencies for. This can
106
- either be python3.8, python3.9, python3.10, python3.11, python3.12, python3.13 or python3.14.
107
+ either be python3.8, python3.9, python3.10, python3.11, python3.12, python3.13, python3.14 or python3.15.
107
108
  These are currently the only supported values.
108
109
 
109
110
  :type osutils: :class:`lambda_builders.utils.OSUtils`
@@ -217,6 +218,7 @@ class DependencyBuilder(object):
217
218
  "cp312": (2, 34),
218
219
  "cp313": (2, 34),
219
220
  "cp314": (2, 34),
221
+ "cp315": (2, 34),
220
222
  }
221
223
  # Fallback version if we're on an unknown python version
222
224
  # not in _RUNTIME_GLIBC.
@@ -115,8 +115,16 @@ class PythonPipWorkflow(BaseWorkflow):
115
115
  # folder
116
116
  if self.dependencies_dir and self.combine_dependencies:
117
117
  # when copying downloaded dependencies back to artifacts folder, don't exclude anything
118
- # symlinking python dependencies is disabled for now since it is breaking sam local commands
119
- if False and is_experimental_build_improvements_enabled(self.experimental_flags):
118
+ #
119
+ # Symlink instead of copy only when building a layer. sam local mounts a function's
120
+ # build folder into the container, where links pointing outside it break (#391).
121
+ # A layer that creates parent packages also copies, so that step can't write into
122
+ # dependencies_dir through a link.
123
+ if (
124
+ self.is_building_layer
125
+ and not self._should_create_parent_packages()
126
+ and is_experimental_build_improvements_enabled(self.experimental_flags)
127
+ ):
120
128
  self._actions.append(LinkSourceAction(self.dependencies_dir, artifacts_dir))
121
129
  else:
122
130
  self._actions.append(CopySourceAction(self.dependencies_dir, artifacts_dir))
@@ -115,8 +115,8 @@ The workflow uses a smart dispatch system that recognizes actual manifest files:
115
115
 
116
116
  **Smart Lock File Detection:**
117
117
  - Look for requirements.txt first
118
- - When `pyproject.toml` is the manifest, automatically checks for `uv.lock` in the same directory
119
- - If `uv.lock` exists alongside `pyproject.toml`, uses lock-based build for precise dependencies
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
120
  - If no `uv.lock`, uses standard pyproject.toml build with UV's lock and export workflow
121
121
 
122
122
  **Important:** `uv.lock` is NOT a standalone manifest - it's a lock file that enhances `pyproject.toml` builds when present.
@@ -125,6 +125,13 @@ The workflow uses a smart dispatch system that recognizes actual manifest files:
125
125
 
126
126
  **For pyproject.toml with uv.lock present:**
127
127
  - Use `uv export` to convert lock file to requirements.txt format
128
+ - Export with `--locked`, reusing the lock's resolution mode, prerelease mode, fork strategy, and `exclude-newer`
129
+ cutoff so export validates rather than rewrites the existing lock. Stale locks fail the build;
130
+ run `uv lock` explicitly after dependency changes.
131
+ - For relative cutoffs, replay `exclude-newer-span` instead of the lock's placeholder `exclude-newer` date.
132
+ Python 3.10 uses the runtime dependency `tomli` to read lock options; Python 3.11+ uses `tomllib`.
133
+ - Replay each `options.exclude-newer-package` entry with `--exclude-newer-package`, preferring its `span`
134
+ over the placeholder `timestamp` for relative per-package cutoffs.
128
135
  - Install using `uv pip install` with platform targeting (--python-platform)
129
136
  - Provides reproducible builds with locked dependency versions AND cross-platform support
130
137
 
@@ -145,7 +152,9 @@ the `--python-platform` flag for cross-platform wheel selection.
145
152
  #### Step 3: Configure Lambda-compatible installation
146
153
 
147
154
  UV is configured with Lambda-specific settings:
148
- - Target platform: `linux` (Amazon Linux 2)
155
+ - Target platform: explicit manylinux targets, independent of the build host's glibc.
156
+ Python 3.8-3.11 use `manylinux_2_17` (the AL2-compatible download target used by the pip workflow);
157
+ Python 3.12+ use `manylinux_2_34` for Amazon Linux 2023.
149
158
  - Target architecture: `x86_64` or `aarch64`
150
159
  - Python version matching Lambda runtime
151
160
  - Prefer wheels over source distributions for faster builds
@@ -211,6 +220,39 @@ config = {
211
220
  }
212
221
  ```
213
222
 
223
+ ### Build options
224
+
225
+ `PythonUvWorkflow` reads these keys from the workflow `options` and passes them to `uv export`.
226
+ SAM CLI maps them from `Metadata.BuildProperties`.
227
+
228
+ | Option | SAM CLI property | Type | `uv export` effect |
229
+ |---|---|---|---|
230
+ | `uv_groups` | `UvGroups` | list of str | `--group <name>` per entry |
231
+ | `uv_extras` | `UvExtras` | list of str | `--extra <name>` per entry |
232
+ | `uv_all_extras` | `UvAllExtras` | bool | `--all-extras` |
233
+ | `uv_prune` | `UvPrune` | list of str | `--prune <name>` per entry: drops the package and any dependency only it needs |
234
+
235
+ Default groups stay excluded (`--no-default-groups`); `uv_groups` adds groups on top of that.
236
+ `uv_prune` is meant for packages the Lambda runtime already ships, such as `boto3`. The function then
237
+ uses the runtime's version, which AWS picks, not the version in `uv.lock`.
238
+ The build fails with a clear message, instead of ignoring the option, when:
239
+ - a value has the wrong type, or an unknown `uv_*` key is given;
240
+ - `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);
242
+ - a `uv_prune` name is not a package in `uv.lock`, which `uv export --prune` would otherwise ignore.
243
+
244
+ ### Settings from pyproject.toml
245
+
246
+ The workflow runs `uv export` and `uv pip install` from the project, so uv reads its own settings there.
247
+ Build-control settings in `[tool.uv]` (`no-build`, `no-build-package`, `no-binary`, `no-binary-package`) apply
248
+ 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
250
+ Python version come from the function's architecture and runtime, default groups are excluded, and nothing
251
+ is installed editable. In a uv workspace only the workspace root's `pyproject.toml` settings are used; a
252
+ member's `[tool.uv]` and `[tool.uv.pip]` tables are ignored. An unknown key in either table makes uv ignore
253
+ every setting in that file. The build log shows uv's warning about it (the workflow logs every `warning:`
254
+ that uv prints, once per build), so check the key names against uv's settings reference.
255
+
214
256
  ### Caching
215
257
 
216
258
  The workflow does not pass `--cache-dir` unless a caller supplies one, so UV uses its own
@@ -224,6 +266,11 @@ and across successive builds. Pointing UV at the build's scratch directory inste
224
266
  discard the cache every time, because that directory is deleted when the build finishes — every
225
267
  function would then re-download its entire dependency set on every build.
226
268
 
269
+ The one exception is a default cache location that can't be created, such as `/.cache/uv` for a
270
+ container build run as a host uid with no home directory (`sam build --use-container
271
+ --mount-with WRITE`). Then the build uses `uv-cache` under the scratch directory and logs a
272
+ warning. Nothing is lost there, because such a container starts with an empty cache anyway.
273
+
227
274
  ### Compatibility with Existing Workflows
228
275
 
229
276
  The UV workflow is designed to be a drop-in replacement for the pip workflow:
@@ -271,13 +318,17 @@ CAPABILITY = Capability(
271
318
 
272
319
  The workflow uses intelligent manifest detection:
273
320
 
274
- **Supported Manifests (in order of preference):**
275
- 1. `requirements.txt` - Standard pip format
276
- 2. `requirements-*.txt` - Environment-specific variants (dev, test, prod, etc.)
277
- 3. `pyproject.toml` - Modern Python project manifest
321
+ **Auto-detection (when no manifest path is given), in order of preference:**
322
+ 1. `pyproject.toml`, when it is the uv project: a `uv.lock` sits beside it, or its `[project]` table declares a non-empty `dependencies` list
323
+ 2. `requirements.txt`, then `requirements-prod.txt`
324
+ 3. `pyproject.toml` otherwise (metadata or tool settings only, empty `dependencies`, or `dynamic` dependencies)
325
+
326
+ `requirements-dev.txt` and `requirements-test.txt` are never auto-detected: development and test dependencies do not belong in a Lambda package. They can still be passed as an explicit manifest path.
327
+
328
+ On Python 3.10 without `tomli`, declared dependencies cannot be read, so only a `uv.lock` makes `pyproject.toml` win over a requirements file.
278
329
 
279
330
  **Smart Lock File Enhancement:**
280
- - When `pyproject.toml` is used, automatically detects `uv.lock` in the same directory
331
+ - When `pyproject.toml` is used, automatically detects `uv.lock` at the resolved workspace or project root
281
332
  - If `uv.lock` exists, uses lock-based build for reproducible dependencies
282
333
  - If no `uv.lock`, uses standard pyproject.toml workflow with UV's lock and export
283
334
 
@@ -304,6 +355,39 @@ Note: `requirements.in` (pip-tools format) is not supported to keep the implemen
304
355
  - **UvBuildError**: Package build failures
305
356
  - **LockFileError**: Lock file parsing or validation errors
306
357
 
358
+ #### Workspace Resolution Failure Policy
359
+
360
+ Workspace discovery runs before the lock-file lookup for every `pyproject.toml` build.
361
+ The compatibility fallback to the project directory is deliberately limited to two cases:
362
+
363
+ - A plain `X.Y.Z` UV version is numerically below `0.9.9`; the workspace command is not invoked.
364
+ - The workspace command exits unsuccessfully and stderr contains `unrecognized subcommand 'workspace'`.
365
+
366
+ Both cases log at DEBUG. They additionally emit a WARNING only if a `pyproject.toml`
367
+ in the project directory or an ancestor contains a `tool.uv.workspace` table. This is
368
+ only a diagnostic hint: `members` and `exclude` are not evaluated, so the warning does
369
+ not assert membership or change the chosen root or build path. Unreadable or invalid
370
+ TOML is logged at DEBUG and skipped. The helper lazily imports `tomllib`, or optional
371
+ `tomli` on Python 3.10. If neither is available, it logs at DEBUG and skips configuration
372
+ inspection; no TOML parser is required to build dependencies.
373
+ This preserves the previous behavior for standalone projects
374
+ using unsupported UV versions; it does not provide workspace support for those versions.
375
+ Unknown or prerelease version strings are tested by invoking the workspace command rather
376
+ than assuming support or lack of support.
377
+
378
+ All other command failures raise `UvBuildError` with the diagnostic, and a successful exit
379
+ with empty or whitespace-only output also raises because it supplies no root directory.
380
+ These outcomes do not establish that the project is outside a workspace. Falling back could
381
+ miss an existing workspace-root lock, trigger lock generation, or resolve local dependencies
382
+ from the wrong directory.
383
+
384
+ This intentionally favors stopping on uncertain workspace discovery over continuing a
385
+ potentially incorrect build. Consequently, a standalone project that previously built may
386
+ now stop if workspace discovery fails for an unknown reason. That compatibility limitation
387
+ is accepted rather than treating permission, configuration, or process-start failures as
388
+ evidence that the workspace command is unsupported. The original diagnostic is surfaced
389
+ instead of recommending an upgrade for an unknown cause.
390
+
307
391
  #### Platform Compatibility Matrix
308
392
  | Python Version | x86_64 | arm64 | Status |
309
393
  |---------------|--------|-------|---------|
@@ -8,7 +8,7 @@ from typing import Optional
8
8
  from aws_lambda_builders.actions import ActionFailedError, BaseAction, Purpose
9
9
  from aws_lambda_builders.architecture import X86_64
10
10
 
11
- from .exceptions import MissingUvError, UvBuildError, UvInstallationError
11
+ from .exceptions import LockFileError, MissingUvError, UvBuildError, UvInstallationError
12
12
  from .packager import PythonUvDependencyBuilder, SubprocessUv, UvRunner
13
13
  from .utils import OSUtils, UvConfig
14
14
 
@@ -72,5 +72,5 @@ class PythonUvBuildAction(BaseAction):
72
72
  architecture=self.architecture,
73
73
  config=self.config,
74
74
  )
75
- except (MissingUvError, UvInstallationError, UvBuildError) as ex:
75
+ except (LockFileError, MissingUvError, UvInstallationError, UvBuildError) as ex:
76
76
  raise ActionFailedError(str(ex))