mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 02:22:19 +00:00
Add support for .env
and custom env files in uv run
(#8811)
## Summary This PR pulls in https://github.com/astral-sh/uv/pull/8263 and https://github.com/astral-sh/uv/pull/8463, which were originally merged into the v0.5 tracking branch but can now be committed separately, as we've made `.env` loading opt-in. In summary: - `.env` loading is now opt-in (`--env-file .env`). - `.env` remains supported on `uv run`, so it's meant for providing environment variables to the run command, rather than to uv itself. --------- Co-authored-by: Eduardo González Vaquero <47718648+edugzlez@users.noreply.github.com>
This commit is contained in:
parent
224622b089
commit
a42c09fdfb
12 changed files with 326 additions and 3 deletions
|
@ -2656,6 +2656,17 @@ pub struct RunArgs {
|
|||
#[arg(long)]
|
||||
pub no_editable: bool,
|
||||
|
||||
/// Load environment variables from a `.env` file.
|
||||
///
|
||||
/// Can be provided multiple times, with subsequent files overriding values defined in
|
||||
/// previous files.
|
||||
#[arg(long, env = EnvVars::UV_ENV_FILE)]
|
||||
pub env_file: Vec<PathBuf>,
|
||||
|
||||
/// Avoid reading environment variables from a `.env` file.
|
||||
#[arg(long, value_parser = clap::builder::BoolishValueParser::new(), env = EnvVars::UV_NO_ENV_FILE)]
|
||||
pub no_env_file: bool,
|
||||
|
||||
/// The command to run.
|
||||
///
|
||||
/// If the path to a Python script (i.e., ending in `.py`), it will be
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue