Skip to content

Commit

Permalink
Add CACHEDIR.TAG to uv-created virtualenvs (astral-sh#1653)
Browse files Browse the repository at this point in the history
## Summary

Just as we mark virtualenvs as `gitignore`d by default, we should also
mark them as `CACHEDIR.TAG`, to ensure that they aren't included in
backups, etc.

Closes astral-sh#1648.

## Test Plan

Ran `cargo run venv` and:

```
❯ ls .venv
CACHEDIR.TAG bin          lib          pyvenv.cfg
```
  • Loading branch information
charliermarsh authored Feb 18, 2024
1 parent c04f597 commit 5cdc6de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/gourgeist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ uv-cache = { path = "../uv-cache" }
uv-interpreter = { path = "../uv-interpreter" }

anstream = { workspace = true }
cachedir = { workspace = true }
camino = { workspace = true }
clap = { workspace = true, features = ["derive"], optional = true }
directories = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions crates/gourgeist/src/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ pub fn create_bare_venv(location: &Utf8Path, interpreter: &Interpreter) -> io::R
};
let bin_dir = location.join(bin_name);

// Add the CACHEDIR.TAG.
cachedir::ensure_tag(&location)?;

// Create a `.gitignore` file to ignore all files in the venv.
fs::write(location.join(".gitignore"), "*")?;

// Different names for the python interpreter
Expand Down

0 comments on commit 5cdc6de

Please sign in to comment.