Skip to content

[image_spec]: copy Cargo path deps for maturin packages into Docker context#32

Open
summer-exa wants to merge 1 commit intomasterfrom
devin/1770752273-cargo-path-deps
Open

[image_spec]: copy Cargo path deps for maturin packages into Docker context#32
summer-exa wants to merge 1 commit intomasterfrom
devin/1770752273-cargo-path-deps

Conversation

@summer-exa
Copy link

Why are the changes needed?

When building Flyte container images for packages that use maturin (Rust crates with Python bindings via cdylib), the image build fails because Cargo path dependencies declared in Cargo.toml are not copied into the Docker build context.

_copy_local_packages_and_update_lock only copies Python packages listed in uv.lock. Rust-only crates referenced via path = "..." in Cargo.toml are invisible to uv, so maturin/cargo fails at build time with:

Unable to update /root/local_packages/rust/shared/exarpc
Caused by: failed to read `/root/local_packages/rust/shared/exarpc/Cargo.toml`
Caused by: No such file or directory (os error 2)

What changes were proposed in this pull request?

Adds _copy_cargo_path_deps() which, after copying a local package into the Docker build context, checks if it contains a Cargo.toml and recursively copies any Rust path dependencies ([dependencies], [build-dependencies], [dev-dependencies]) into local_packages/ preserving their relative directory structure so that Cargo path references continue to resolve.

The function:

  • Tracks already-copied paths to avoid cycles
  • Respects .gitignore/.dockerignore patterns
  • Recurses to handle transitive Cargo path deps

How was this patch tested?

  • ruff check passes
  • py_compile passes
  • No unit tests added — this is difficult to test without a real monorepo with maturin packages and a uv.lock referencing them

Human review checklist

  • Python version compat: set[str] | None type hint uses 3.10+ syntax — verify this matches flytekit's minimum supported Python version (may need Optional[Set[str]] from typing instead)
  • Silent error swallowing: except Exception: return on Cargo.toml parse — should this warn/log instead of silently skipping?
  • dev-dependencies: Currently copies dev-dependencies path deps too, which may pull unnecessary crates into the image. Intentional for safety but worth confirming.

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Link to Devin run | Requested by: @summer-exa

…er context

Co-Authored-By: summer@exa.ai <summer@exa.ai>
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants