Files
uv/crates/uv-python/src/lib.rs
T

92 lines
2.6 KiB
Rust
Raw Normal View History

//! Find requested Python interpreters and query interpreters for information.
use thiserror::Error;
2024-10-14 21:48:13 +00:00
#[cfg(test)]
use uv_static::EnvVars;
pub use crate::discovery::{
find_python_installations, EnvironmentPreference, Error as DiscoveryError, PythonDownloads,
PythonNotFound, PythonPreference, PythonRequest, PythonSource, PythonVariant, VersionRequest,
};
pub use crate::environment::{InvalidEnvironment, InvalidEnvironmentKind, PythonEnvironment};
2024-06-14 13:03:16 -04:00
pub use crate::implementation::ImplementationName;
pub use crate::installation::{PythonInstallation, PythonInstallationKey};
pub use crate::interpreter::{Error as InterpreterError, Interpreter};
pub use crate::pointer_size::PointerSize;
2024-06-06 16:15:28 -04:00
pub use crate::prefix::Prefix;
pub use crate::python_version::PythonVersion;
pub use crate::target::Target;
pub use crate::version_files::{
2024-08-21 16:41:20 -05:00
PythonVersionFile, PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME,
};
pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment};
2024-07-19 13:19:28 -04:00
mod discovery;
pub mod downloads;
mod environment;
mod implementation;
2024-07-03 08:44:29 -04:00
mod installation;
mod interpreter;
mod libc;
pub mod managed;
2024-08-29 22:56:41 +02:00
#[cfg(windows)]
mod microsoft_store;
pub mod platform;
mod pointer_size;
2024-06-06 16:15:28 -04:00
mod prefix;
#[cfg(windows)]
mod py_launcher;
mod python_version;
mod target;
mod version_files;
mod virtualenv;
#[cfg(not(test))]
pub(crate) fn current_dir() -> Result<std::path::PathBuf, std::io::Error> {
std::env::current_dir()
}
#[cfg(test)]
pub(crate) fn current_dir() -> Result<std::path::PathBuf, std::io::Error> {
2024-10-14 21:48:13 +00:00
std::env::var_os(EnvVars::PWD)
.map(std::path::PathBuf::from)
.map(Ok)
.unwrap_or(std::env::current_dir())
}
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
VirtualEnv(#[from] virtualenv::Error),
#[error(transparent)]
Query(#[from] interpreter::Error),
#[error(transparent)]
Discovery(#[from] discovery::Error),
#[error(transparent)]
2024-07-03 08:44:29 -04:00
ManagedPython(#[from] managed::Error),
#[error(transparent)]
Download(#[from] downloads::Error),
// TODO(zanieb) We might want to ensure this is always wrapped in another type
#[error(transparent)]
2024-07-03 08:44:29 -04:00
KeyError(#[from] installation::PythonInstallationKeyError),
#[error(transparent)]
2024-07-03 08:44:29 -04:00
MissingPython(#[from] PythonNotFound),
#[error(transparent)]
MissingEnvironment(#[from] environment::EnvironmentNotFound),
#[error(transparent)]
InvalidEnvironment(#[from] environment::InvalidEnvironment),
}
// The mock interpreters are not valid on Windows so we don't have unit test coverage there
// TODO(zanieb): We should write a mock interpreter script that works on Windows
#[cfg(all(test, unix))]
mod tests;