Skip to content

fix(launcher): force uv to use managed Python (avoids macOS Xcode prompt)#322

Merged
lstein merged 2 commits into
masterfrom
lstein/fix/launcher-only-managed-python
Jun 9, 2026
Merged

fix(launcher): force uv to use managed Python (avoids macOS Xcode prompt)#322
lstein merged 2 commits into
masterfrom
lstein/fix/launcher-only-managed-python

Conversation

@lstein

@lstein lstein commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Problem

When first-run setup runs on macOS, uv tool install can trigger an Xcode
"install command-line developer tools" dialog — an annoying interruption for
non-technical users the signed launcher is meant to serve.

Root cause

uv's default --python-preference is managed, which prefers a managed
interpreter but falls back to a system/framework CPython if it finds a
matching version. On macOS that's the non-relocatable python.org build at
/Library/Frameworks/Python.framework/.... Building the tool venv from it makes
uv rewrite the copied executable's Mach-O load paths with install_name_tool
(part of the Xcode CLT) — which pops the install dialog when the CLT aren't
present. uv's managed (python-build-standalone) builds are relocatable, so they
never invoke install_name_tool.

Fix

Set UV_PYTHON_PREFERENCE=only-managed in the launcher's uvEnv() — the single
place that configures every uv invocation, so python install, tool install,
and the GPU-reinstall path are all consistent. The launcher already pins 3.12
and runs uv python install 3.12 first; this just closes the gap where
tool install could still bind to the framework interpreter.

Also folded the same flags (--python 3.12 --python-preference only-managed)
into the documented PyPI/uv recipe across the docs and READMEs, since the
manual CLI path hit the same prompt.

Tests

  • New TestUVEnvForcesManagedPython asserts the env carries only-managed.
  • go build, go vet, go test, gofmt -l all clean.

🤖 Generated with Claude Code

lstein and others added 2 commits June 8, 2026 20:12
…mpt)

On macOS, uv's default --python-preference ("managed") still falls back to a
system/framework CPython when one matches. The python.org framework build is not
relocatable, so building the tool venv from it makes uv rewrite Mach-O load
paths with install_name_tool, which triggers the Xcode Command Line Tools
install dialog during first-run setup.

Set UV_PYTHON_PREFERENCE=only-managed in the launcher's uvEnv() so every uv call
(python install, tool install, GPU reinstall) uses uv's relocatable managed
builds and never the framework Python. The launcher already pins/installs a
managed 3.12; this just closes the gap where tool install could still pick up
the framework interpreter. Add a regression test for the env.

Fold the same flags into the documented PyPI/uv recipe across the docs and
READMEs (--python 3.12 --python-preference only-managed) so the CLI path avoids
the prompt too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lstein lstein enabled auto-merge (squash) June 9, 2026 00:12
@lstein lstein merged commit a96dc83 into master Jun 9, 2026
9 checks passed
lstein added a commit that referenced this pull request Jun 9, 2026
…d of forcing managed Python (#324)

PR #322 tried to suppress the macOS "install Xcode Command Line Tools"
dialog by forcing uv to use a managed CPython (UV_PYTHON_PREFERENCE=
only-managed), on the theory that the framework Python's non-relocatable
binary was what made uv run install_name_tool. Testing on a cold Mac
disproved that: uv runs install_name_tool while building the tool venv
regardless of which interpreter it uses, so the dialog fires immediately
either way. The tools aren't actually needed — the install completes fine
whether the user accepts or cancels — and there's no clean way to stop the
prompt.

So revert the only-managed approach and instead set the right expectation:
before uv runs on macOS, if `xcode-select -p` shows the Command Line Tools
are absent, print a short warning that the dialog will appear and is safe
to dismiss, pause ~5s so it's read, then proceed.

- launcher/uv.go: drop UV_PYTHON_PREFERENCE=only-managed; add
  warnIfXcodeToolsMissing() and call it at the top of install().
- launcher/uv_test.go: TestUVEnvForcesManagedPython -> TestUVEnvRedirectsState
  (the dir-redirect coverage stays; the only-managed assertion is gone).
- docs/README: revert the `--python 3.12 --python-preference only-managed`
  recipe back to `uv tool install photomapai --torch-backend auto` and drop
  the now-false note that it avoids the macOS prompt.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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