Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support --link-mode=symlink #5147

Closed
hutch3232 opened this issue Jul 17, 2024 · 10 comments
Closed

feature: support --link-mode=symlink #5147

hutch3232 opened this issue Jul 17, 2024 · 10 comments
Labels
enhancement New feature or improvement to existing functionality good first issue Good for newcomers help wanted Contribution especially encouraged

Comments

@hutch3232
Copy link
Contributor

Currently --link-mode supports copy, hardlink, and clone. I have my UV_CACHE_DIR set to a mounted drive which prevents hardlinks and cloning ("invalid cross-device link"). Symlinks would work, however. This could really increase performance for my situation, rather than copying over a bunch of files. When I work in R, I use renv which uses symlinks to a central cache successfully in the proposed way: https://github.com/rstudio/renv.

More details about the specific use-case:
I work in ephemeral docker containers. My workflow is generally to start by running uv pip sync requirements.txt which currently is triggering a copy for each package. I mount a persistent drive to my container so that my uv cache persists from session to session. Also worth noting that some collaborators mount the same drive and use the same cache, so that we benefit from each others' install time. Hopefully that isn't too risky, but it has worked well so far and works great in the aforementioned renv package in R.

Related issue:
#2103

Thanks for making this amazing project!

@charliermarsh
Copy link
Member

I don't mind supporting this, I was kinda waiting for it to be requested.

@charliermarsh charliermarsh added enhancement New feature or improvement to existing functionality good first issue Good for newcomers help wanted Contribution especially encouraged labels Jul 17, 2024
@charliermarsh
Copy link
Member

Should be straightforward-ish if anyone wants to submit a PR -- it'd basically be copying the hardlink code, but changing the operation we use at the end.

@danielenricocahall
Copy link
Contributor

Hi @charliermarsh! Would it be a matter of swapping fs::hard_link for std::os::unix::fs::symlink (after adding a Symlink value to the enum and mapping it to a new callable?

@charliermarsh
Copy link
Member

@danielenricocahall - Yeah that sounds roughly correct to me.

@charliermarsh
Copy link
Member

We'll also need std::os::windows::fs::symlink_file or similar on Windows which will probably fail for most people due to how symlink permissions work on Windows, but that's fine, they just shouldn't opt-in to this mode if they haven't enabled symlinks :)

charliermarsh pushed a commit that referenced this issue Jul 19, 2024
## Summary

Addressing this [issue](#5147) by
adding the capability for Symbolic linking as a link mode when
installing or syncing dependencies.
@charliermarsh
Copy link
Member

Closed by #5208. Thanks @danielenricocahall!

@helderco
Copy link

I was about to ask for this for the same reasons and just found out it’s been released already! 🎉

@skshetry
Copy link
Contributor

skshetry commented Jul 20, 2024

I wonder if uv can symlink packages directly instead of per-file (similar to virtualenv --symlink-app-data), which could make it much faster than hardlink/clone.

On macOS, you can also clone a directory, but I see that uv already does just that.

@charliermarsh
Copy link
Member

That’s a good idea. We should probably symlink at the directory level.

@charliermarsh
Copy link
Member

#5244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality good first issue Good for newcomers help wanted Contribution especially encouraged
Projects
None yet
Development

No branches or pull requests

5 participants