mirror of https://github.com/astral-sh/uv
Configurable bootstrap dir (#1772)
Add a `UV_BOOTSTRAP_DIR` option to configure the python bootstrap directory. This is helpful when working across multiple platforms in a single IDE session.
This commit is contained in:
parent
5d53040465
commit
0f520d8716
|
|
@ -52,6 +52,8 @@ Alternatively, you can install `zstandard` from PyPI, then run:
|
|||
python3.12 scripts/bootstrap/install.py
|
||||
```
|
||||
|
||||
You can configure the bootstrapping directory with `UV_BOOTSTRAP_DIR`.
|
||||
|
||||
### Local testing
|
||||
|
||||
You can invoke your development version of uv with `cargo run -- <args>`. For example:
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ use assert_fs::fixture::PathChild;
|
|||
use fs_err::os::unix::fs::symlink as symlink_file;
|
||||
#[cfg(windows)]
|
||||
use fs_err::os::windows::fs::symlink_file;
|
||||
use platform_host::Platform;
|
||||
use regex::Regex;
|
||||
use uv_cache::Cache;
|
||||
|
||||
use platform_host::Platform;
|
||||
use uv_cache::Cache;
|
||||
use uv_interpreter::find_requested_python;
|
||||
|
||||
// Exclude any packages uploaded after this date.
|
||||
|
|
@ -117,14 +117,26 @@ pub fn venv_to_interpreter(venv: &Path) -> PathBuf {
|
|||
/// Python versions are sorted from newest to oldest.
|
||||
pub fn bootstrapped_pythons() -> Option<Vec<PathBuf>> {
|
||||
// Current dir is `<project root>/crates/uv`.
|
||||
let bootstrapped_pythons = std::env::current_dir()
|
||||
let project_root = std::env::current_dir()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("bin")
|
||||
.join("versions");
|
||||
.to_path_buf();
|
||||
let boostrap_dir = if let Some(boostrap_dir) = env::var_os("UV_BOOTSTRAP_DIR") {
|
||||
let boostrap_dir = PathBuf::from(boostrap_dir);
|
||||
if boostrap_dir.is_absolute() {
|
||||
boostrap_dir
|
||||
} else {
|
||||
// cargo test changes directory to the test crate, but doesn't tell us from where the user is running the
|
||||
// tests. We'll assume that it's the project root.
|
||||
project_root.join(boostrap_dir)
|
||||
}
|
||||
} else {
|
||||
project_root.join("bin")
|
||||
};
|
||||
let bootstrapped_pythons = boostrap_dir.join("versions");
|
||||
let Ok(bootstrapped_pythons) = fs_err::read_dir(bootstrapped_pythons) else {
|
||||
return None;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
|
|
@ -48,6 +49,9 @@ except ImportError:
|
|||
# Setup some file paths
|
||||
THIS_DIR = Path(__file__).parent
|
||||
ROOT_DIR = THIS_DIR.parent.parent
|
||||
if bin_dir := os.environ.get("UV_BOOTSTRAP_DIR"):
|
||||
BIN_DIR = Path(bin_dir)
|
||||
else:
|
||||
BIN_DIR = ROOT_DIR / "bin"
|
||||
INSTALL_DIR = BIN_DIR / "versions"
|
||||
VERSIONS_FILE = ROOT_DIR / ".python-versions"
|
||||
|
|
|
|||
Loading…
Reference in New Issue