diff --git a/aws_lambda_builders/__init__.py b/aws_lambda_builders/__init__.py index d7910614c..d28d17012 100644 --- a/aws_lambda_builders/__init__.py +++ b/aws_lambda_builders/__init__.py @@ -5,5 +5,5 @@ # Changing version will trigger a new release! # Please make the version change as the last step of your development. -__version__ = "1.49.0" +__version__ = "1.50.0" RPC_PROTOCOL_VERSION = "0.3" diff --git a/aws_lambda_builders/workflows/python_pip/packager.py b/aws_lambda_builders/workflows/python_pip/packager.py index 65a802028..3fc48427a 100644 --- a/aws_lambda_builders/workflows/python_pip/packager.py +++ b/aws_lambda_builders/workflows/python_pip/packager.py @@ -203,6 +203,9 @@ class DependencyBuilder(object): "cp37m": (2, 17), "cp38": (2, 26), "cp39": (2, 26), + "cp310": (2, 26), + "cp311": (2, 26), + "cp312": (2, 26), } # Fallback version if we're on an unknown python version # not in _RUNTIME_GLIBC. diff --git a/aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py b/aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py index 33c61ee36..223fcc633 100644 --- a/aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py +++ b/aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py @@ -100,6 +100,12 @@ def run(self, command, cwd): if "RUST_LOG" not in os.environ: os.environ["RUST_LOG"] = "debug" LOG.debug("RUST_LOG environment variable set to `%s`", os.environ.get("RUST_LOG")) + + if not os.getenv("CARGO_TARGET_DIR"): + # This results in the "target" dir being created under the member dir of a cargo workspace + # This is for supporting sam build for a Cargo Workspace project + os.environ["CARGO_TARGET_DIR"] = "target" + cargo_process = self._osutils.popen( command, stderr=subprocess.PIPE, diff --git a/requirements/dev.txt b/requirements/dev.txt index aaa78e54d..794851f13 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,4 +1,4 @@ -coverage==7.4.4 +coverage==7.5.1 flake8==3.8.4 pytest-cov==5.0.0 @@ -8,5 +8,5 @@ parameterized==0.9.0 pyelftools~=0.31 # Used to verify the generated Go binary architecture in integration tests (utils.py) # formatter -black==24.4.0 -ruff==0.4.1 +black==24.4.2 +ruff==0.4.3 diff --git a/tests/integration/workflows/rust_cargo/test_rust_cargo.py b/tests/integration/workflows/rust_cargo/test_rust_cargo.py index 2fb846718..fd3930a1e 100644 --- a/tests/integration/workflows/rust_cargo/test_rust_cargo.py +++ b/tests/integration/workflows/rust_cargo/test_rust_cargo.py @@ -9,8 +9,8 @@ from aws_lambda_builders.workflows.rust_cargo.feature_flag import EXPERIMENTAL_FLAG_CARGO_LAMBDA -def rm_target_lambda(base): - shutil.rmtree(os.path.join(base, "target", "lambda"), ignore_errors=True) +def rm_target(base): + shutil.rmtree(os.path.join(base, "target"), ignore_errors=True) class TestRustCargo(TestCase): @@ -52,7 +52,7 @@ def test_failed_build_project(self): def test_builds_hello_project(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "hello") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( source_dir, @@ -70,7 +70,7 @@ def test_builds_hello_project(self): def test_builds_hello_project_with_artifact_name(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "hello") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( source_dir, @@ -89,7 +89,7 @@ def test_builds_hello_project_with_artifact_name(self): def test_builds_hello_project_for_arm64(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "hello") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( source_dir, @@ -109,10 +109,10 @@ def test_builds_hello_project_for_arm64(self): def test_builds_workspaces_project_with_bin_name(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "workspaces") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( - source_dir, + f"{source_dir}", self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "Cargo.toml"), @@ -125,10 +125,30 @@ def test_builds_workspaces_project_with_bin_name(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) + self.assertIn("foo", os.listdir(os.path.join(source_dir, "target", "lambda"))) + + def test_builds_workspace_member(self): + source_dir = os.path.join(self.TEST_DATA_FOLDER, "workspaces") + rm_target(source_dir) + + self.builder.build( + f"{source_dir}/bar", + self.artifacts_dir, + self.scratch_dir, + os.path.join(source_dir, "Cargo.toml"), + runtime=self.runtime, + experimental_flags=[EXPERIMENTAL_FLAG_CARGO_LAMBDA], + ) + + expected_files = {"bootstrap"} + output_files = set(os.listdir(self.artifacts_dir)) + + self.assertEqual(expected_files, output_files) + self.assertIn("bar", os.path.join(source_dir, "bar", "target", "lambda")) def test_builds_workspaces_project_with_package_option(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "workspaces") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( source_dir, @@ -147,7 +167,7 @@ def test_builds_workspaces_project_with_package_option(self): def test_builds_multi_function_project_with_function_a(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "multi-binary") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( source_dir, @@ -166,7 +186,7 @@ def test_builds_multi_function_project_with_function_a(self): def test_builds_multi_function_project_with_function_b(self): source_dir = os.path.join(self.TEST_DATA_FOLDER, "multi-binary") - rm_target_lambda(source_dir) + rm_target(source_dir) self.builder.build( source_dir,