Skip to content
Merged
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
5 changes: 3 additions & 2 deletions aws_lambda_builders/workflows/python_uv/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ def _uv_config_from_options(self, manifest_path):
f"but this build uses {os.path.basename(manifest_path) if manifest_path else 'no manifest'}"
)

project_name = self._project_name(manifest_path)
# Only uv_prune needs the project name, and it's only set here with a pyproject.toml manifest
project_name = self._project_name(manifest_path) if values.get("uv_prune") else None
if project_name and any(
normalize_package_name(name) == normalize_package_name(project_name) for name in values.get("uv_prune", [])
normalize_package_name(name) == normalize_package_name(project_name) for name in values["uv_prune"]
):
self._fail(f"Build option uv_prune cannot name the project being built ({project_name})")

Expand Down
13 changes: 13 additions & 0 deletions tests/unit/workflows/python_uv/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ def test_compile_bytecode_on_requirements_build_is_allowed(self):
config = self._workflow({"uv_compile_bytecode": True}, manifest=requirements).actions[0].config
self.assertTrue(config.compile_bytecode)

def test_compile_bytecode_without_manifest_builds_without_dependencies(self):
os.remove(self.pyproject)
workflow = self._workflow({"uv_compile_bytecode": True}, manifest=os.path.join(self.source_dir, "missing.txt"))
self.assertEqual(len(workflow.actions), 1)
self.assertIsInstance(workflow.actions[0], CopySourceAction)

def test_truthy_env_without_manifest_builds_without_dependencies(self):
os.environ["UV_COMPILE_BYTECODE"] = "1"
os.remove(self.pyproject)
workflow = self._workflow({"build_logical_id": "Fn"}, manifest=os.path.join(self.source_dir, "missing.txt"))
self.assertEqual(len(workflow.actions), 1)
self.assertIsInstance(workflow.actions[0], CopySourceAction)

def test_export_option_with_compile_bytecode_on_requirements_build_fails(self):
requirements = os.path.join(self.source_dir, "requirements.txt")
open(requirements, "w").close()
Expand Down
Loading