Skip to content

Commit

Permalink
Fixes (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Apr 21, 2024
1 parent 45a63f3 commit 13dd72e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
***Added:***

- Update default distributions to 20240415
- Support using UV for virtual environment creation and project installation

***Fixed:***

- The PATH environment variable is now updated to include the installation's directory of executables

## 0.16.0 - 2024-03-24

Expand Down
43 changes: 33 additions & 10 deletions src/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,41 @@ use tempfile::tempdir;

use crate::{app, compression, fs_utils, network, process};

#[cfg(windows)]
const PATH_SEPARATOR: char = ';';

#[cfg(not(windows))]
const PATH_SEPARATOR: char = ':';

fn apply_env_vars(command: &mut Command) {
let python_path = app::python_path();
let python_dir = python_path.parent().unwrap();
let exe_paths = if app::full_isolation() && cfg!(windows) {
format!(
"{}{}{}",
python_dir.to_string_lossy(),
PATH_SEPARATOR,
python_dir.join("Scripts").to_string_lossy(),
)
} else {
format!("{}", python_dir.to_string_lossy())
};
match env::var_os("PATH") {
Some(path) => {
command.env(
"PATH",
format!("{}{}{}", exe_paths, PATH_SEPARATOR, path.to_string_lossy()),
);
}
None => {
command.env("PATH", exe_paths);
}
}

if !app::full_isolation() {
command.env("VIRTUAL_ENV", app::python_path().parent().unwrap());
command.env("VIRTUAL_ENV", python_dir);
} else if app::uv_as_installer() {
command.env("UV_SYSTEM_PYTHON", "true");
}

if !app::pass_location() {
Expand Down Expand Up @@ -134,15 +166,6 @@ pub fn pip_install_command() -> Command {

if app::uv_as_installer() {
command.arg("install");
if app::full_isolation() {
command.args([
"--python",
app::install_dir()
.join(app::distribution_python_path())
.to_string_lossy()
.as_ref(),
]);
}
} else {
command.args([
"install",
Expand Down

0 comments on commit 13dd72e

Please sign in to comment.