mirror of https://github.com/astral-sh/uv
Print activation instructions for a venv after one has been created (#1580)
This commit is contained in:
parent
d05cb8464a
commit
7741e1c51a
|
|
@ -195,5 +195,22 @@ async fn venv_impl(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg!(windows) {
|
||||||
|
writeln!(
|
||||||
|
printer,
|
||||||
|
// This should work whether the user is on CMD or PowerShell:
|
||||||
|
"Activate with: {}\\Scripts\\activate",
|
||||||
|
path.normalized_display().cyan()
|
||||||
|
)
|
||||||
|
.into_diagnostic()?;
|
||||||
|
} else {
|
||||||
|
writeln!(
|
||||||
|
printer,
|
||||||
|
"Activate with: source {}/bin/activate",
|
||||||
|
path.normalized_display().cyan()
|
||||||
|
)
|
||||||
|
.into_diagnostic()?;
|
||||||
|
};
|
||||||
|
|
||||||
Ok(ExitStatus::Success)
|
Ok(ExitStatus::Success)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,17 @@ fn create_venv() -> Result<()> {
|
||||||
|
|
||||||
// Create a virtual environment at `.venv`.
|
// Create a virtual environment at `.venv`.
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -45,6 +50,7 @@ fn create_venv() -> Result<()> {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Using Python [VERSION] interpreter at [PATH]
|
Using Python [VERSION] interpreter at [PATH]
|
||||||
Creating virtualenv at: /home/ferris/project/.venv
|
Creating virtualenv at: /home/ferris/project/.venv
|
||||||
|
Activate with: source /home/ferris/project/.venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -52,12 +58,17 @@ fn create_venv() -> Result<()> {
|
||||||
|
|
||||||
// Create a virtual environment at the same location, which should replace it.
|
// Create a virtual environment at the same location, which should replace it.
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -78,6 +89,7 @@ fn create_venv() -> Result<()> {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Using Python [VERSION] interpreter at [PATH]
|
Using Python [VERSION] interpreter at [PATH]
|
||||||
Creating virtualenv at: /home/ferris/project/.venv
|
Creating virtualenv at: /home/ferris/project/.venv
|
||||||
|
Activate with: source /home/ferris/project/.venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -94,12 +106,14 @@ fn create_venv_defaults_to_cwd() -> Result<()> {
|
||||||
let venv = temp_dir.child(".venv");
|
let venv = temp_dir.child(".venv");
|
||||||
|
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(&filter_prompt, "Activate with: source .venv/bin/activate"),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -119,6 +133,7 @@ fn create_venv_defaults_to_cwd() -> Result<()> {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Using Python [VERSION] interpreter at [PATH]
|
Using Python [VERSION] interpreter at [PATH]
|
||||||
Creating virtualenv at: .venv
|
Creating virtualenv at: .venv
|
||||||
|
Activate with: source .venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -135,12 +150,17 @@ fn seed() -> Result<()> {
|
||||||
let venv = temp_dir.child(".venv");
|
let venv = temp_dir.child(".venv");
|
||||||
|
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -163,6 +183,7 @@ fn seed() -> Result<()> {
|
||||||
Using Python [VERSION] interpreter at [PATH]
|
Using Python [VERSION] interpreter at [PATH]
|
||||||
Creating virtualenv at: /home/ferris/project/.venv
|
Creating virtualenv at: /home/ferris/project/.venv
|
||||||
+ pip==23.3.1
|
+ pip==23.3.1
|
||||||
|
Activate with: source /home/ferris/project/.venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -179,12 +200,17 @@ fn seed_older_python_version() -> Result<()> {
|
||||||
let venv = temp_dir.child(".venv");
|
let venv = temp_dir.child(".venv");
|
||||||
|
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -209,6 +235,7 @@ fn seed_older_python_version() -> Result<()> {
|
||||||
+ setuptools==68.2.2
|
+ setuptools==68.2.2
|
||||||
+ pip==23.3.1
|
+ pip==23.3.1
|
||||||
+ wheel==0.41.3
|
+ wheel==0.41.3
|
||||||
|
Activate with: source /home/ferris/project/.venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -317,9 +344,14 @@ fn create_venv_python_patch() -> Result<()> {
|
||||||
let venv = temp_dir.child(".venv");
|
let venv = temp_dir.child(".venv");
|
||||||
|
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(r"interpreter at .+", "interpreter at [PATH]"),
|
(r"interpreter at .+", "interpreter at [PATH]"),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -406,12 +438,17 @@ fn empty_dir_exists() -> Result<()> {
|
||||||
venv.create_dir_all()?;
|
venv.create_dir_all()?;
|
||||||
|
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -432,6 +469,7 @@ fn empty_dir_exists() -> Result<()> {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Using Python [VERSION] interpreter at [PATH]
|
Using Python [VERSION] interpreter at [PATH]
|
||||||
Creating virtualenv at: /home/ferris/project/.venv
|
Creating virtualenv at: /home/ferris/project/.venv
|
||||||
|
Activate with: source /home/ferris/project/.venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -497,12 +535,17 @@ fn virtualenv_compatibility() -> Result<()> {
|
||||||
|
|
||||||
// Create a virtual environment at `.venv`, passing the redundant `--clear` flag.
|
// Create a virtual environment at `.venv`, passing the redundant `--clear` flag.
|
||||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||||
|
let filter_prompt = r"Activate with: (?:.*)\\Scripts\\activate";
|
||||||
let filters = &[
|
let filters = &[
|
||||||
(
|
(
|
||||||
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
r"Using Python 3\.\d+\.\d+ interpreter at .+",
|
||||||
"Using Python [VERSION] interpreter at [PATH]",
|
"Using Python [VERSION] interpreter at [PATH]",
|
||||||
),
|
),
|
||||||
(&filter_venv, "/home/ferris/project/.venv"),
|
(&filter_venv, "/home/ferris/project/.venv"),
|
||||||
|
(
|
||||||
|
&filter_prompt,
|
||||||
|
"Activate with: source /home/ferris/project/.venv/bin/activate",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
uv_snapshot!(filters, Command::new(get_bin())
|
uv_snapshot!(filters, Command::new(get_bin())
|
||||||
.arg("venv")
|
.arg("venv")
|
||||||
|
|
@ -524,6 +567,7 @@ fn virtualenv_compatibility() -> Result<()> {
|
||||||
warning: virtualenv's `--clear` has no effect (uv always clears the virtual environment).
|
warning: virtualenv's `--clear` has no effect (uv always clears the virtual environment).
|
||||||
Using Python [VERSION] interpreter at [PATH]
|
Using Python [VERSION] interpreter at [PATH]
|
||||||
Creating virtualenv at: /home/ferris/project/.venv
|
Creating virtualenv at: /home/ferris/project/.venv
|
||||||
|
Activate with: source /home/ferris/project/.venv/bin/activate
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue