Skip to content

Commit

Permalink
Add current toolchains to Python resolution (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer authored Nov 15, 2023
1 parent 48ae960 commit 4599ffc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions crates/huak-package-manager/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,21 @@ impl Workspace {
fn new_python_environment(&self) -> HuakResult<PythonEnvironment> {
// Get a snapshot of the environment.
let env = self.environment();

// Get the first Python `Interpreter` path found from the `PATH`
// environment variable.
let Some(python_path) = env.python_paths().next() else {
// Include toolchain installations when resolving for a Python interpreter to use.
// If a toolchain cannot be resolved then the first Python path found from the
// environment is used.
let Some(python_path) = self
.resolve_local_toolchain(None)
.ok()
.and_then(|tc| {
// TODO(cnpryer): Proxy better + Refactor
// We use the venv Python.
PythonEnvironment::new(tc.root().join(".venv"))
.ok()
.map(|venv| venv.python_path().to_owned())
})
.or_else(|| env.python_paths().next().map(PathBuf::from))
else {
return Err(Error::PythonNotFound);
};

Expand Down
2 changes: 1 addition & 1 deletion crates/huak-toolchain/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod tests {
dunce::canonicalize(&toolchain).unwrap()
);

db.remove_scope(&dir).unwrap();
db.remove_scope(dir).unwrap();

let table = db.doc().get("scopes").unwrap();

Expand Down

0 comments on commit 4599ffc

Please sign in to comment.