mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Add color to python pin
CLI (#5215)
## Summary 
This commit is contained in:
parent
12dd450a8e
commit
7762d78281
4 changed files with 61 additions and 43 deletions
|
@ -14,10 +14,11 @@ pub use crate::prefix::Prefix;
|
|||
pub use crate::python_version::PythonVersion;
|
||||
pub use crate::target::Target;
|
||||
pub use crate::version_files::{
|
||||
request_from_version_file, requests_from_version_file, PYTHON_VERSIONS_FILENAME,
|
||||
PYTHON_VERSION_FILENAME,
|
||||
request_from_version_file, requests_from_version_file, write_version_file,
|
||||
PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME,
|
||||
};
|
||||
pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment};
|
||||
|
||||
mod discovery;
|
||||
pub mod downloads;
|
||||
mod environment;
|
||||
|
@ -83,19 +84,19 @@ pub enum Error {
|
|||
// TODO(zanieb): We should write a mock interpreter script that works on Windows
|
||||
#[cfg(all(test, unix))]
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
use indoc::{formatdoc, indoc};
|
||||
|
||||
use std::{
|
||||
env,
|
||||
ffi::{OsStr, OsString},
|
||||
path::{Path, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use assert_fs::{fixture::ChildPath, prelude::*, TempDir};
|
||||
use indoc::{formatdoc, indoc};
|
||||
use temp_env::with_vars;
|
||||
use test_log::test;
|
||||
|
||||
use assert_fs::{fixture::ChildPath, prelude::*, TempDir};
|
||||
use uv_cache::Cache;
|
||||
|
||||
use crate::{
|
||||
|
|
|
@ -46,6 +46,12 @@ pub async fn request_from_version_file() -> Result<Option<PythonRequest>, std::i
|
|||
}
|
||||
}
|
||||
|
||||
/// Write a version to a .`python-version` file.
|
||||
pub async fn write_version_file(version: &str) -> Result<(), std::io::Error> {
|
||||
debug!("Writing Python version `{version}` to `{PYTHON_VERSION_FILENAME}`");
|
||||
fs::tokio::write(PYTHON_VERSION_FILENAME, format!("{version}\n")).await
|
||||
}
|
||||
|
||||
async fn read_versions_file() -> Result<Option<Vec<String>>, std::io::Error> {
|
||||
match fs::tokio::read_to_string(PYTHON_VERSIONS_FILENAME).await {
|
||||
Ok(content) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue