Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve directory-level standalone build symlinks (#9723)
## Summary This PR improves our "don't fully resolve symlinks" behavior for `python-build-standalone` builds based on learnings from astral-sh/python-build-standalone#380 (comment). Specifically, we can now robustly detect whether a target executable will lead to a valid `prefix` or not, and iteratively resolve symlinks until we find a valid target executable. ## Test Plan ### Direct symlink to `python` Correctly resolves to the symlink target, rather than the symlink itself. ``` ❯ ln -s /Users/crmarsh/.local/share/uv/python/cpython-3.12.6-macos-aarch64-none/bin/python foo ❯ cargo run venv --python ./foo ❯ cat .venv/pyvenv.cfg home = /Users/crmarsh/.local/share/uv/python/cpython-3.12.6-macos-aarch64-none/bin implementation = CPython uv = 0.5.7 version_info = 3.12.6 include-system-site-packages = false prompt = uv ❯ .venv/bin/python -c "import sys" ``` ### Symlink to the Python installation Correctly does _not_ resolve the symlink. ``` ❯ ln -s /Users/crmarsh/.local/share/uv/python/cpython-3.12.6-macos-aarch64-none bar ❯ cargo run venv --python ./bar ❯ cat .venv/pyvenv.cfg home = /Users/crmarsh/workspace/uv/bar/bin implementation = CPython uv = 0.5.7 version_info = 3.12.6 include-system-site-packages = false prompt = uv ❯ .venv/bin/python -c "import sys" ``` ### Direct symlink to `python` in a symlinked Python installation Correctly resolves the direct symlink, but not the symlink of the Python installation. ``` ❯ ln -s bar/bin/python baz ❯ cargo run venv --python ./baz ❯ cat .venv/pyvenv.cfg home = /Users/crmarsh/workspace/uv/bar/bin implementation = CPython uv = 0.5.7 version_info = 3.12.6 include-system-site-packages = false prompt = uv ❯ .venv/bin/python -c "import sys" ```
- Loading branch information