Move uv-interpreter::managed::* modules into crate top-level (#4020)

Should be no functional changes, just some file renames in preparation
for exposing toolchain management.
This commit is contained in:
Zanie Blue 2024-06-05 08:27:30 -04:00 committed by GitHub
parent 2be93c0b2c
commit 5db7f7b3ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 17 additions and 21 deletions

View file

@ -13,9 +13,8 @@ use tokio::time::Instant;
use tracing::{info, info_span, Instrument};
use uv_fs::Simplified;
use uv_interpreter::managed::{
DownloadResult, Error, InstalledToolchains, PythonDownload, PythonDownloadRequest,
};
use uv_interpreter::downloads::{DownloadResult, Error, PythonDownload, PythonDownloadRequest};
use uv_interpreter::managed::InstalledToolchains;
#[derive(Parser, Debug)]
pub(crate) struct FetchPythonArgs {

View file

@ -1,12 +1,12 @@
#!/usr/bin/env python3.12
"""
Fetch Python version metadata.
Fetch Python version download metadata.
Generates the `python-version-metadata.json` file.
Generates the `download-metadata.json` file.
Usage:
python fetch-version-metadata.py
python fetch-download-metadata.py
Acknowledgements:
@ -30,7 +30,7 @@ RELEASE_URL = "https://api.github.com/repos/indygreg/python-build-standalone/rel
HEADERS = {
"X-GitHub-Api-Version": "2022-11-28",
}
VERSIONS_FILE = SELF_DIR / "python-version-metadata.json"
VERSIONS_FILE = SELF_DIR / "download-metadata.json"
FLAVOR_PREFERENCES = [
"shared-pgo",
"shared-noopt",

View file

@ -143,7 +143,7 @@ impl FromStr for PythonDownloadRequest {
}
}
include!("python_versions.inc");
include!("downloads.inc");
pub enum DownloadResult {
AlreadyAvailable(PathBuf),

View file

@ -14,6 +14,7 @@ pub use crate::target::Target;
pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment};
mod discovery;
pub mod downloads;
mod environment;
mod implementation;
mod interpreter;

View file

@ -8,7 +8,8 @@ use std::str::FromStr;
use uv_state::{StateBucket, StateStore};
use crate::managed::downloads::Error;
// TODO(zanieb): Separate download and managed error types
pub use crate::downloads::Error;
use crate::platform::{Arch, Libc, Os};
use crate::python_version::PythonVersion;
@ -27,8 +28,8 @@ impl InstalledToolchains {
/// Prefer, in order:
/// 1. The specific toolchain directory specified by the user, i.e., `UV_TOOLCHAIN_DIR`
/// 2. A bucket in the system-appropriate user-level data directory, e.g., `~/.local/uv/toolchains`
/// 3. A bucket in the local data directory, e.g., `./.uv/toolchains`
/// 2. A directory in the system-appropriate user-level data directory, e.g., `~/.local/uv/toolchains`
/// 3. A directory in the local data directory, e.g., `./.uv/toolchains`
pub fn from_settings() -> Result<Self, io::Error> {
if let Some(toolchain_dir) = std::env::var_os("UV_TOOLCHAIN_DIR") {
Self::from_path(toolchain_dir)

View file

@ -1,5 +0,0 @@
pub use crate::managed::downloads::{DownloadResult, Error, PythonDownload, PythonDownloadRequest};
pub use crate::managed::find::{InstalledToolchains, Toolchain};
mod downloads;
mod find;

View file

@ -1,12 +1,12 @@
#!/usr/bin/env python3.12
"""
Generate static Rust code from Python version metadata.
Generate static Rust code from Python version download metadata.
Generates the `python_versions.rs` file from the `python_versions.rs.mustache` template.
Generates the `downloads.inc` file from the `downloads.inc.mustache` template.
Usage:
python template-version-metadata.py
python template-download-metadata.py
"""
import sys
@ -18,8 +18,8 @@ from pathlib import Path
CRATE_ROOT = Path(__file__).parent
WORKSPACE_ROOT = CRATE_ROOT.parent.parent
VERSION_METADATA = CRATE_ROOT / "python-version-metadata.json"
TEMPLATE = CRATE_ROOT / "src" / "managed" / "python_versions.inc.mustache"
VERSION_METADATA = CRATE_ROOT / "download-metadata.json"
TEMPLATE = CRATE_ROOT / "src" / "downloads.inc.mustache"
TARGET = TEMPLATE.with_suffix("")