Skip to content

Virtual environments created by uv are backed up by Time Machine #8796

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

Open
mikepqr opened this issue Nov 4, 2024 · 2 comments
Open

Virtual environments created by uv are backed up by Time Machine #8796

mikepqr opened this issue Nov 4, 2024 · 2 comments
Labels
enhancement New feature or improvement to existing functionality

Comments

@mikepqr
Copy link

mikepqr commented Nov 4, 2024

uv creates CACHEDIR.TAG in .venv, indicating that backup tools need not make copies of this directory. Unfortunately, as far as I can tell, the builtin macOS backup tool Time Machine does not respect this file, meaning that the virtual environment is backed up incrementally.

While I appreciate that the right way to fix this is for Apple to teach Time Machine to respect CACHEDIR.TAG, the probability of that seems remote.

Is there any interest in handling this in uv? One way to do this would be to shell out to tmutil addexclusion .venv/ when the environment is created. This is what e.g. https://github.com/stevegrunwell/asimov/ does and it is supported by macOS.

For what it's worth, the performance impact of this would be measurable, but perhaps tolerable since this would only need to run each time .venv is created:

$ hyperfine "tmutil addexclusion .venv"
Benchmark 1: tmutil addexclusion .venv
  Time (mean ± σ):      18.0 ms ±   6.3 ms    [User: 4.3 ms, System: 4.3 ms]
  Range (min … max):     9.6 ms …  39.1 ms    95 runs
@edmorley
Copy link
Contributor

@zanieb
Copy link
Member

zanieb commented Feb 26, 2025

Thanks @edmorley! That looks pretty interesting.

@konstin konstin added the enhancement New feature or improvement to existing functionality label Feb 28, 2025
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
Projects
None yet
Development

No branches or pull requests

4 participants