Skip to content

Commit

Permalink
Set prompt when creating venv (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
aisk committed Jul 25, 2023
1 parent e163ec8 commit 877233b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion rye/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ pub fn install(
// make sure we have a compatible python version
let py_ver = fetch(py_ver, output)?;

create_virtualenv(output, &self_venv, &py_ver, &target_venv_path)?;
create_virtualenv(
output,
&self_venv,
&py_ver,
&target_venv_path,
requirement.name.as_str(),
)?;

let mut cmd = Command::new(self_venv.join(VENV_BIN).join("pip"));
cmd.arg("--python")
Expand Down
2 changes: 1 addition & 1 deletion rye/src/piptools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn get_pip_tools_bin(py_ver: &PythonVersion, output: CommandOutput) -> Result<Pa
if output != CommandOutput::Quiet {
echo!("Creating virtualenv for pip-tools");
}
create_virtualenv(output, &self_venv, py_ver, &venv)?;
create_virtualenv(output, &self_venv, py_ver, &venv, "pip-tools")?;

let mut cmd = Command::new(self_venv.join(VENV_BIN).join("pip"));
cmd.arg("--python")
Expand Down
6 changes: 5 additions & 1 deletion rye/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ pub fn sync(cmd: SyncOptions) -> Result<(), Error> {
);
echo!("Python version: {}", style(&py_ver).cyan());
}
create_virtualenv(output, &self_venv, &py_ver, &venv)
let prompt = pyproject.name().unwrap_or("venv");
create_virtualenv(output, &self_venv, &py_ver, &venv, prompt)
.context("failed creating virtualenv ahead of sync")?;
fs::write(
venv.join("rye-venv.json"),
Expand Down Expand Up @@ -288,6 +289,7 @@ pub fn create_virtualenv(
self_venv: &Path,
py_ver: &PythonVersion,
venv: &Path,
prompt: &str,
) -> Result<(), Error> {
let py_bin = get_toolchain_python_bin(py_ver)?;
let mut venv_cmd = Command::new(self_venv.join(VENV_BIN).join("virtualenv"));
Expand All @@ -300,6 +302,8 @@ pub fn create_virtualenv(
venv_cmd.arg("-p");
venv_cmd.arg(&py_bin);
venv_cmd.arg("--no-seed");
venv_cmd.arg("--prompt");
venv_cmd.arg(prompt);
venv_cmd.arg("--");
venv_cmd.arg(venv);
let status = venv_cmd
Expand Down

0 comments on commit 877233b

Please sign in to comment.