fix: support uv-managed Python in dev mode project creation on macOS#44
Open
AMagicPear wants to merge 1 commit into
Open
fix: support uv-managed Python in dev mode project creation on macOS#44AMagicPear wants to merge 1 commit into
AMagicPear wants to merge 1 commit into
Conversation
On macOS, venv --copies fails with SIGABRT when ensurepip is invoked because copied Python binaries have hardcoded paths that resolve to the original venv location. Additionally, --copies on macOS copies the python executable but not libpython3.12.dylib, causing 'Library not loaded' at runtime since @executable_path/../lib/libpython3.12.dylib points to the original. Fix: use symlink mode (the default) instead of --copies, and bootstrap pip manually with 'pip install --target' after venv creation to avoid ensurepip entirely. Also add a fallback in _ensure_pip for the bundled runtime path: if ensurepip fails, copy pip from the host Python's site-packages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS with uv-managed Python (and other non-conda Python installations), creating a new project in dev mode fails with SIGABRT:
Even when ensurepip doesn't abort, a subsequent 'Library not loaded' error appears because
venv --copiescopies the python executable but notlibpython3.12.dylib:Root Cause
On macOS, Python binaries are linked with
@executable_path/../lib/libpython3.12.dylib. Whenvenv --copiesis used:libpython3.12.dylibis NOT copied — it still lives at the original Python'slib/path@executable_pathresolves to the target.venv/, where the dylib doesn't existensurepip(called internally byvenv) also fails because it writes to hardcoded paths in the original venvFix
project_model.py: Remove
--copiesfromvenvcall (use symlink mode, the default). After venv creation, manually bootstrap pip using the host Python's pip withpip install --targetto avoid ensurepip entirely.stage_bundled_python_runtime.py: Add a fallback in
_ensure_pip()— if ensurepip fails, copy pip from the host Python's site-packages instead of aborting.Testing