Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- uses: astral-sh/setup-uv@v7
- run: test -f "./.github/ISSUE_TEMPLATE/Bug_report.md" # prevent Bug_report.md from being renamed or deleted
- run: make pr

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ jobs:
3.13
3.14

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Set up Node.js
if: contains(fromJSON('["build-integ", "build-integ-java-python-provided", "build-integ-dotnet-node-ruby", "build-integ-arm64"]'), matrix.test_suite) && matrix.container_runtime == 'no-container'
uses: actions/setup-node@v6
Expand Down
3 changes: 3 additions & 0 deletions samcli/commands/_utils/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class ExperimentalFlag:
)
}
RustCargoLambda = ExperimentalEntry("experimentalCargoLambda", EXPERIMENTAL_ENV_VAR_PREFIX + "RUST_CARGO_LAMBDA")
UvPackageManager = ExperimentalEntry(
"experimentalUvPackageManager", EXPERIMENTAL_ENV_VAR_PREFIX + "UV_PACKAGE_MANAGER"
)


def is_experimental_enabled(config_entry: ExperimentalEntry) -> bool:
Expand Down
28 changes: 15 additions & 13 deletions samcli/commands/build/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def run(self) -> None:
)

self._check_exclude_warning()
self._check_rust_cargo_experimental_flag()
self._check_build_method_experimental_flag()

for f in self.get_resources_to_build().functions:
EventTracker.track_event(EventName.BUILD_FUNCTION_RUNTIME.value, f.runtime)
Expand Down Expand Up @@ -696,24 +696,26 @@ def _check_exclude_warning(self) -> None:
if self._resource_identifier in excludes:
LOG.warning(self._EXCLUDE_WARNING_MESSAGE)

def _check_rust_cargo_experimental_flag(self) -> None:
def _check_build_method_experimental_flag(self) -> None:
"""
Prints warning message and confirms if user wants to use beta feature
"""
WARNING_MESSAGE = (
'Build method "rust-cargolambda" is a beta feature.\n'
"Please confirm if you would like to proceed\n"
'You can also enable this beta feature with "sam build --beta-features".'
)
EXPERIMENTAL_BUILD_METHODS = {
"rust-cargolambda": ExperimentalFlag.RustCargoLambda,
"python-uv": ExperimentalFlag.UvPackageManager,
}

resources_to_build = self.get_resources_to_build()
is_building_rust = False
for function in resources_to_build.functions:
if function.metadata and function.metadata.get("BuildMethod", "") == "rust-cargolambda":
is_building_rust = True
break
if function.metadata and function.metadata.get("BuildMethod", "") in EXPERIMENTAL_BUILD_METHODS:
build_method = function.metadata.get("BuildMethod", "")
WARNING_MESSAGE = (
f'Build method "{build_method}" is a beta feature.\n'
"Please confirm if you would like to proceed\n"
'You can also enable this beta feature with "sam build --beta-features".'
)

if is_building_rust:
prompt_experimental(ExperimentalFlag.RustCargoLambda, WARNING_MESSAGE)
prompt_experimental(EXPERIMENTAL_BUILD_METHODS[build_method], WARNING_MESSAGE)

@property
def build_in_source(self) -> Optional[bool]:
Expand Down
16 changes: 11 additions & 5 deletions samcli/lib/build/app_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ def _build_layer(
manifest_context_path = str(
pathlib.Path(self._base_dir, layer_metadata.get("ContextPath", code_dir)).resolve()
)
manifest_path = self._manifest_path_override or os.path.join(manifest_context_path, config.manifest_name)
manifest_path = (
self._manifest_path_override
if self._manifest_path_override
else (os.path.join(manifest_context_path, config.manifest_name) if config.manifest_name else None)
)

# By default prefer to build in-process for speed
scratch_dir_path = (
Expand Down Expand Up @@ -731,8 +735,10 @@ def _build_function( # pylint: disable=R1710
manifest_context_path = str(
pathlib.Path(self._base_dir, metadata.get("ContextPath", code_dir)).resolve()
)
manifest_path = self._manifest_path_override or os.path.join(
manifest_context_path, config.manifest_name
manifest_path = (
self._manifest_path_override
if self._manifest_path_override
else (os.path.join(manifest_context_path, config.manifest_name) if config.manifest_name else None)
)
scratch_dir_path = (
LambdaBuildContainer.get_container_dirs(code_dir, manifest_path)["scratch_dir"]
Expand Down Expand Up @@ -916,7 +922,7 @@ def _build_function_in_process(
source_dir: str,
artifacts_dir: str,
scratch_dir: str,
manifest_path: str,
manifest_path: Optional[str],
runtime: str,
architecture: str,
options: Optional[Dict],
Expand Down Expand Up @@ -962,7 +968,7 @@ def _build_function_on_container(
config: CONFIG,
source_dir: str,
artifacts_dir: str,
manifest_path: str,
manifest_path: Optional[str],
runtime: str,
architecture: str,
options: Optional[Dict],
Expand Down
2 changes: 2 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NODEJS_NPM_ESBUILD_CONFIG,
PROVIDED_MAKE_CONFIG,
PYTHON_PIP_CONFIG,
PYTHON_UV_CONFIG,
RUBY_BUNDLER_CONFIG,
RUST_CARGO_LAMBDA_CONFIG,
)
Expand Down Expand Up @@ -155,6 +156,7 @@ def get_workflow_config(
"dotnet7": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"dotnet": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"rust-cargolambda": BasicWorkflowSelector(RUST_CARGO_LAMBDA_CONFIG),
"python-uv": BasicWorkflowSelector(PYTHON_UV_CONFIG),
}

selectors_by_runtime = {
Expand Down
10 changes: 10 additions & 0 deletions samcli/lib/build/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
must_mount_with_write_in_container=False,
)

PYTHON_UV_CONFIG = CONFIG(
language="python",
dependency_manager="uv",
application_framework=None,
manifest_name=None,
executable_search_paths=None,
must_mount_with_write_in_container=False,
)

NODEJS_NPM_CONFIG = CONFIG(
language="nodejs",
dependency_manager="npm",
Expand Down Expand Up @@ -117,6 +126,7 @@

ALL_CONFIGS: List[CONFIG] = [
PYTHON_PIP_CONFIG,
PYTHON_UV_CONFIG,
NODEJS_NPM_CONFIG,
RUBY_BUNDLER_CONFIG,
JAVA_GRADLE_CONFIG,
Expand Down
15 changes: 2 additions & 13 deletions schema/samcli.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where these changes come from, they came up after running make pr locally.

Original file line number Diff line number Diff line change
Expand Up @@ -2202,11 +2202,12 @@
"title": "parameter_overrides",
"type": [
"array",
"object",
"string"
],
"description": "String that contains AWS CloudFormation parameter overrides encoded as key=value pairs.",
"items": {
"type": "string"
"$ref": "#/$defs/parameter_overrides_items"
}
},
"stack_name": {
Expand Down Expand Up @@ -2271,18 +2272,6 @@
"description": "Available parameters for the list stack outputs command:\n* stack_name:\nName of corresponding deployed stack.\n* output:\nOutput the results from the command in a given output format (json or table).\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* save_params:\nSave the parameters provided via the command line to the configuration file.",
"type": "object",
"properties": {
"parameter_overrides": {
"title": "parameter_overrides",
"type": [
"array",
"object",
"string"
],
"description": "String that contains AWS CloudFormation parameter overrides encoded as key=value pairs.",
"items": {
"$ref": "#/$defs/parameter_overrides_items"
}
},
"stack_name": {
"title": "stack_name",
"type": "string",
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/buildcmd/build_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,11 @@ def _verify_built_artifact(self, build_dir, function_logical_id, expected_files,

@pytest.mark.python
class BuildIntegPythonBase(BuildIntegBase):
EXPECTED_FILES_PROJECT_MANIFEST = {
EXPECTED_FILES = {
"__init__.py",
"main.py",
"numpy",
# 'cryptography',
"requirements.txt",
}

FUNCTION_LOGICAL_ID = "Function"
Expand All @@ -748,19 +747,23 @@ def _test_with_default_requirements(
codeuri,
use_container,
relative_path,
manifest="requirements.txt",
do_override=True,
check_function_only=False,
architecture=None,
beta_features=False,
):
if use_container and (SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD):
self.skipTest(SKIP_DOCKER_MESSAGE)
overrides = self.get_override(runtime, codeuri, architecture, "main.handler") if do_override else None
cmdlist = self.get_command_list(use_container=use_container, parameter_overrides=overrides)
cmdlist = self.get_command_list(
use_container=use_container, parameter_overrides=overrides, beta_features=beta_features, debug=True
)

run_command(cmdlist, cwd=self.working_dir)

self._verify_built_artifact(
self.default_build_dir, self.FUNCTION_LOGICAL_ID, self.EXPECTED_FILES_PROJECT_MANIFEST
self.default_build_dir, self.FUNCTION_LOGICAL_ID, (self.EXPECTED_FILES | {manifest})
)

if not check_function_only:
Expand Down
Loading
Loading