Skip to content

Commit

Permalink
Fix paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Dec 9, 2024
1 parent 717e6e9 commit da25c67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

#### 🐞 Fixes

- Fixed Python virtual env bin path not being available for tasks when `python.version` is not
defined.

## 1.30.4

#### 🐞 Fixes
Expand Down
20 changes: 12 additions & 8 deletions legacy/python/platform/src/python_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl Platform for PythonPlatform {
_hasher_config: &HasherConfig,
) -> miette::Result<()> {
let deps = BTreeMap::from_iter(load_lockfile_dependencies(manifest_path.to_path_buf())?);

hasher.hash_content(PythonToolchainHash {
version: self
.config
Expand All @@ -261,9 +262,11 @@ impl Platform for PythonPlatform {
_hasher_config: &HasherConfig,
) -> miette::Result<()> {
let mut deps = BTreeMap::new();

if let Some(pip_requirements) = find_requirements_txt(&project.root, &self.workspace_root) {
deps = BTreeMap::from_iter(load_lockfile_dependencies(pip_requirements)?);
}

hasher.hash_content(PythonToolchainHash {
version: self
.config
Expand Down Expand Up @@ -295,15 +298,16 @@ impl Platform for PythonPlatform {
if let Ok(python) = self.toolchain.get_for_version(&runtime.requirement) {
if let Some(version) = get_proto_version_env(&python.tool) {
command.env("PROTO_PYTHON_VERSION", version);
command.env(
"PATH",
prepend_path_env_var(get_python_tool_paths(
python,
working_dir,
&self.workspace_root,
)),
);
}

command.env(
"PATH",
prepend_path_env_var(get_python_tool_paths(
python,
working_dir,
&self.workspace_root,
)),
);
}

Ok(command)
Expand Down
10 changes: 7 additions & 3 deletions legacy/python/tool/src/python_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ pub fn get_python_tool_paths(
working_dir: &Path,
workspace_root: &Path,
) -> Vec<PathBuf> {
let mut paths = vec![];

if let Some(venv_root) =
fs::find_upwards_until(&python_tool.config.venv_name, working_dir, workspace_root)
{
vec![venv_root.join("Scripts"), venv_root.join("bin")]
} else {
get_proto_paths(&python_tool.proto_env)
paths.push(venv_root.join("Scripts"));
paths.push(venv_root.join("bin"));
}

paths.extend(get_proto_paths(&python_tool.proto_env));
paths
}

pub struct PythonTool {
Expand Down

0 comments on commit da25c67

Please sign in to comment.