Skip to content

Commit b7f8673

Browse files
committed
feat: make uv accessible by BuildMethod template parameter
1 parent ef77353 commit b7f8673

2 files changed

Lines changed: 16 additions & 26 deletions

File tree

samcli/commands/build/build_context.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ def run(self) -> None:
281281
)
282282

283283
self._check_exclude_warning()
284-
self._check_rust_cargo_experimental_flag()
284+
self._check_build_method_experimental_flag('rust-cargolambda')
285+
self._check_build_method_experimental_flag('python-uv')
285286

286287
for f in self.get_resources_to_build().functions:
287288
EventTracker.track_event(EventName.BUILD_FUNCTION_RUNTIME.value, f.runtime)
@@ -696,24 +697,24 @@ def _check_exclude_warning(self) -> None:
696697
if self._resource_identifier in excludes:
697698
LOG.warning(self._EXCLUDE_WARNING_MESSAGE)
698699

699-
def _check_rust_cargo_experimental_flag(self) -> None:
700+
def _check_build_method_experimental_flag(self, build_method: str) -> None:
700701
"""
701702
Prints warning message and confirms if user wants to use beta feature
702703
"""
703704
WARNING_MESSAGE = (
704-
'Build method "rust-cargolambda" is a beta feature.\n'
705-
"Please confirm if you would like to proceed\n"
705+
f'Build method "{build_method}" is a beta feature.\n'
706+
'Please confirm if you would like to proceed\n'
706707
'You can also enable this beta feature with "sam build --beta-features".'
707708
)
708709
resources_to_build = self.get_resources_to_build()
709-
is_building_rust = False
710+
is_building_experimental = False
710711
for function in resources_to_build.functions:
711-
if function.metadata and function.metadata.get("BuildMethod", "") == "rust-cargolambda":
712-
is_building_rust = True
712+
if function.metadata and function.metadata.get("BuildMethod", "") == build_method:
713+
is_building_experimental = True
713714
break
714715

715-
if is_building_rust:
716-
prompt_experimental(ExperimentalFlag.RustCargoLambda, WARNING_MESSAGE)
716+
if is_building_experimental:
717+
prompt_experimental(ExperimentalFlag.RustCargoLambda if build_method == "rust-cargolambda" else ExperimentalFlag.UvPackageManager, WARNING_MESSAGE)
717718

718719
@property
719720
def build_in_source(self) -> Optional[bool]:

samcli/lib/build/workflow_config.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -157,28 +157,17 @@ def get_workflow_config(
157157
"dotnet7": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
158158
"dotnet": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
159159
"rust-cargolambda": BasicWorkflowSelector(RUST_CARGO_LAMBDA_CONFIG),
160+
"python-uv": BasicWorkflowSelector(PYTHON_UV_CONFIG),
160161
}
161162

162-
use_uv = is_experimental_enabled(ExperimentalFlag.UvPackageManager)
163-
164163
selectors_by_runtime = {
165164
"python3.8": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
166165
"python3.9": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
167-
"python3.10": ConditionalWorkflowSelector(
168-
default=PYTHON_PIP_CONFIG, alternative=PYTHON_UV_CONFIG, use_alternative=use_uv
169-
),
170-
"python3.11": ConditionalWorkflowSelector(
171-
default=PYTHON_PIP_CONFIG, alternative=PYTHON_UV_CONFIG, use_alternative=use_uv
172-
),
173-
"python3.12": ConditionalWorkflowSelector(
174-
default=PYTHON_PIP_CONFIG, alternative=PYTHON_UV_CONFIG, use_alternative=use_uv
175-
),
176-
"python3.13": ConditionalWorkflowSelector(
177-
default=PYTHON_PIP_CONFIG, alternative=PYTHON_UV_CONFIG, use_alternative=use_uv
178-
),
179-
"python3.14": ConditionalWorkflowSelector(
180-
default=PYTHON_PIP_CONFIG, alternative=PYTHON_UV_CONFIG, use_alternative=use_uv
181-
),
166+
"python3.10": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
167+
"python3.11": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
168+
"python3.12": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
169+
"python3.13": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
170+
"python3.14": BasicWorkflowSelector([PYTHON_PIP_CONFIG]),
182171
"nodejs16.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
183172
"nodejs18.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
184173
"nodejs20.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),

0 commit comments

Comments
 (0)