mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-29 11:07:59 +00:00
Create virtualenv if it doesn't exist in project API (#3499)
## Summary This doesn't yet respect `--python` or the `requires-python` in the project itself. Closes #3449.
This commit is contained in:
parent
5f8c3b7e45
commit
835ebe60c6
9 changed files with 83 additions and 21 deletions
|
|
@ -14,6 +14,8 @@ use std::process::ExitStatus;
|
|||
|
||||
use thiserror::Error;
|
||||
|
||||
use uv_fs::Simplified;
|
||||
|
||||
pub use crate::environment::PythonEnvironment;
|
||||
pub use crate::find_python::{find_best_python, find_default_python, find_requested_python};
|
||||
pub use crate::interpreter::Interpreter;
|
||||
|
|
@ -35,13 +37,15 @@ mod virtualenv;
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("Expected `{0}` to be a virtualenv, but `pyvenv.cfg` is missing")]
|
||||
#[error("Expected `{}` to be a virtualenv, but `pyvenv.cfg` is missing", _0.user_display())]
|
||||
MissingPyVenvCfg(PathBuf),
|
||||
#[error("No versions of Python could be found. Is Python installed?")]
|
||||
PythonNotFound,
|
||||
#[error("Failed to locate a virtualenv or Conda environment (checked: `VIRTUAL_ENV`, `CONDA_PREFIX`, and `.venv`). Run `uv venv` to create a virtualenv.")]
|
||||
VenvNotFound,
|
||||
#[error("Failed to locate Python interpreter at `{0}`")]
|
||||
#[error("Virtualenv does not exist at: `{}`", _0.user_display())]
|
||||
VenvDoesNotExist(PathBuf),
|
||||
#[error("Failed to locate Python interpreter at: `{0}`")]
|
||||
RequestedPythonNotFound(String),
|
||||
#[error(transparent)]
|
||||
Io(#[from] io::Error),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue