Skip to content

fix: runfiles staging, copy_style, and pip auto-detection for macOS and Linux#3

Open
hwuiwon wants to merge 1 commit intoflyteorg:mainfrom
hwuiwon:fix/runfiles-staging-and-copy-style
Open

fix: runfiles staging, copy_style, and pip auto-detection for macOS and Linux#3
hwuiwon wants to merge 1 commit intoflyteorg:mainfrom
hwuiwon:fix/runfiles-staging-and-copy-style

Conversation

@hwuiwon
Copy link

@hwuiwon hwuiwon commented Feb 21, 2026

What

Fix several bugs preventing flyte_deploy, flyte_build, and flyte_run (remote) from working on macOS and Linux. Also simplify flyte.bzl by extracting all inline Python into a shared flyte_runner.py.

Bug fixes

  1. copy_style=Nonecopy_style="all"None is undocumented and fragile
  2. Remove interactive_mode — the SDK raises NotImplementedError if True, passing None is a no-op
  3. Runfiles symlink breakage — Bazel runfiles are symlink trees pointing into the output base. Flyte's bundler calls path.relative_to(cwd) which fails since resolved symlinks are outside cwd. Fixed by staging runfiles into a real temp dir with shutil.copytree(symlinks=False) before calling flyte.init()
  4. Proto files invisible to bundler.venv.pth entries point into the original symlink tree and get excluded. Fixed by parsing .venv.pth files and copying those directories into the staging root
  5. Missing pip packages in remote container — extra Bazel pip deps aren't in the base Flyte image. Fixed by walking importlib.metadata to find non-flyte packages and injecting them via image.with_pip_packages()

Simplification

Moved ~315 lines of Python embedded in Starlark .format() strings into bazel/flyte_runner.py. Each macro now generates a one-line wrapper and passes config via py_binary args. flyte.bzl goes from 503 to ~200 lines with zero inline Python. Macro API is unchanged — no consumer BUILD changes needed.

Changes

  • MODULE.bazel — add aspect_rules_py
  • bazel/flyte_runner.py (new) — shared entry point for run/deploy/build
  • bazel/BUILD.bazel — add _flyte_runner_lib py_library
  • bazel/flyte.bzl — replace code generation with CLI-arg-based dispatch

@hwuiwon hwuiwon force-pushed the fix/runfiles-staging-and-copy-style branch 2 times, most recently from 051d45a to 6d740d3 Compare February 21, 2026 00:40
Fix several bugs preventing flyte_deploy, flyte_build, and flyte_run
(remote) from working on macOS and Linux. Extract all inline Python
from Starlark into a shared flyte_runner.py entry point.

Bug fixes:
- Use explicit copy_style=all instead of None
- Remove unused interactive_mode parameter
- Stage runfiles into a real temp dir to fix symlink resolution errors
- Flatten .venv.pth proto entries into the staging root
- Auto-detect extra pip packages missing from the remote container

Refactoring:
- Move ~315 lines of inline Python from .format() strings into
  bazel/flyte_runner.py (real, lintable, testable Python)
- Each macro now generates a one-line wrapper and passes config via
  py_binary args attribute
- flyte.bzl reduced from 503 to ~200 lines, 0 inline Python
- Macro API unchanged — no consumer BUILD file changes needed

Signed-off-by: Hwuiwon Kim <hwuiwon.kim@gmail.com>
@hwuiwon hwuiwon force-pushed the fix/runfiles-staging-and-copy-style branch from a5949b4 to 4f6a590 Compare February 23, 2026 16:21
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.

1 participant