mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Add CACHEDIR.TAG
to uv-created virtualenvs (#1653)
## 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 https://github.com/astral-sh/uv/issues/1648. ## Test Plan Ran `cargo run venv` and: ``` ❯ ls .venv CACHEDIR.TAG bin lib pyvenv.cfg ```
This commit is contained in:
parent
c04f597fae
commit
5cdc6de4a9
3 changed files with 6 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1237,6 +1237,7 @@ name = "gourgeist"
|
||||||
version = "0.0.4"
|
version = "0.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
|
"cachedir",
|
||||||
"camino",
|
"camino",
|
||||||
"clap",
|
"clap",
|
||||||
"directories",
|
"directories",
|
||||||
|
|
|
@ -26,6 +26,7 @@ uv-cache = { path = "../uv-cache" }
|
||||||
uv-interpreter = { path = "../uv-interpreter" }
|
uv-interpreter = { path = "../uv-interpreter" }
|
||||||
|
|
||||||
anstream = { workspace = true }
|
anstream = { workspace = true }
|
||||||
|
cachedir = { workspace = true }
|
||||||
camino = { workspace = true }
|
camino = { workspace = true }
|
||||||
clap = { workspace = true, features = ["derive"], optional = true }
|
clap = { workspace = true, features = ["derive"], optional = true }
|
||||||
directories = { workspace = true }
|
directories = { workspace = true }
|
||||||
|
|
|
@ -108,6 +108,10 @@ pub fn create_bare_venv(location: &Utf8Path, interpreter: &Interpreter) -> io::R
|
||||||
};
|
};
|
||||||
let bin_dir = location.join(bin_name);
|
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"), "*")?;
|
fs::write(location.join(".gitignore"), "*")?;
|
||||||
|
|
||||||
// Different names for the python interpreter
|
// Different names for the python interpreter
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue