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
|
python3.12 scripts/bootstrap/install.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can configure the bootstrapping directory with `UV_BOOTSTRAP_DIR`.
|
||||||
|
|
||||||
### Local testing
|
### Local testing
|
||||||
|
|
||||||
You can invoke your development version of uv with `cargo run -- <args>`. For example:
|
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;
|
use fs_err::os::unix::fs::symlink as symlink_file;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use fs_err::os::windows::fs::symlink_file;
|
use fs_err::os::windows::fs::symlink_file;
|
||||||
use platform_host::Platform;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use uv_cache::Cache;
|
|
||||||
|
|
||||||
|
use platform_host::Platform;
|
||||||
|
use uv_cache::Cache;
|
||||||
use uv_interpreter::find_requested_python;
|
use uv_interpreter::find_requested_python;
|
||||||
|
|
||||||
// Exclude any packages uploaded after this date.
|
// 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.
|
/// Python versions are sorted from newest to oldest.
|
||||||
pub fn bootstrapped_pythons() -> Option<Vec<PathBuf>> {
|
pub fn bootstrapped_pythons() -> Option<Vec<PathBuf>> {
|
||||||
// Current dir is `<project root>/crates/uv`.
|
// Current dir is `<project root>/crates/uv`.
|
||||||
let bootstrapped_pythons = std::env::current_dir()
|
let project_root = std::env::current_dir()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.parent()
|
.parent()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.parent()
|
.parent()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.join("bin")
|
.to_path_buf();
|
||||||
.join("versions");
|
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 {
|
let Ok(bootstrapped_pythons) = fs_err::read_dir(bootstrapped_pythons) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import platform
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -48,7 +49,10 @@ except ImportError:
|
||||||
# Setup some file paths
|
# Setup some file paths
|
||||||
THIS_DIR = Path(__file__).parent
|
THIS_DIR = Path(__file__).parent
|
||||||
ROOT_DIR = THIS_DIR.parent.parent
|
ROOT_DIR = THIS_DIR.parent.parent
|
||||||
BIN_DIR = ROOT_DIR / "bin"
|
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"
|
INSTALL_DIR = BIN_DIR / "versions"
|
||||||
VERSIONS_FILE = ROOT_DIR / ".python-versions"
|
VERSIONS_FILE = ROOT_DIR / ".python-versions"
|
||||||
VERSIONS_METADATA_FILE = THIS_DIR / "versions.json"
|
VERSIONS_METADATA_FILE = THIS_DIR / "versions.json"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue