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
11 changes: 7 additions & 4 deletions agent/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,17 @@ def _parse_additional_packages(self) -> list[str]:
packages = []
for app in pmf:
pyproject = pmf[app]["pyproject"] or {}
deps = pyproject.get("deploy", {}).get("dependencies", {})
pkgs = deps.get("apt", {}).get("packages", [])
# Legacy key, not valid per PEP 518 (only [tool.*] is open to tools)
legacy_pkgs = (
pyproject.get("deploy", {}).get("dependencies", {}).get("apt", {}).get("packages", [])
)
tool_pkgs = pyproject.get("tool", {}).get("frappe-cloud", {}).get("apt-dependencies", [])

for p in pkgs:
for p in [*legacy_pkgs, *tool_pkgs]:
p = p.strip()
packages.append(p)

return packages
return list(dict.fromkeys(packages))

def _inject_additional_packages(self, packages: list[str]):
"""This hack simply injects the additional packages discovered post cloning"""
Expand Down
26 changes: 26 additions & 0 deletions agent/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ def test_check_version(self):
self.assertEqual(ValidationManager.check_version(actual, expected), want)


class TestParseAdditionalPackages(unittest.TestCase):
def test_reads_legacy_and_tool_frappe_cloud_keys(self):
from agent.builder import ContextManager

pyproject = """
[tool.frappe-cloud]
apt-dependencies = ["poppler-utils", "libmagic1"]

[deploy.dependencies.apt]
packages = ["libmagic1", " ffmpeg "]
"""
with tempfile.TemporaryDirectory() as build_directory:
app_path = os.path.join(build_directory, "apps", "my_app")
os.makedirs(app_path)
with open(os.path.join(app_path, "pyproject.toml"), "w") as f:
f.write(pyproject)

context = SimpleNamespace(
build_directory=build_directory,
clone_instructions=[{"app": "my_app"}],
)
packages = ContextManager._parse_additional_packages(context)

self.assertEqual(packages, ["libmagic1", "ffmpeg", "poppler-utils"])


class TestStampStepEnd(unittest.TestCase):
def test_done_line_gets_the_utc_time_the_step_ended(self):
from agent.builder import stamp_step_end
Expand Down
Loading