diff --git a/src/config/env_directive/venv.rs b/src/config/env_directive/venv.rs index f2eadee11f..cea0f3d2cb 100644 --- a/src/config/env_directive/venv.rs +++ b/src/config/env_directive/venv.rs @@ -1,4 +1,4 @@ -use crate::backend; +use crate::{backend, plugins}; use crate::cli::args::BackendArg; use crate::cmd::CmdLineRunner; use crate::config::config_file::trust_check; @@ -48,9 +48,7 @@ impl EnvResults { } }); let python_path = tv.map(|tv| { - tv.install_path() - .join("bin") - .join("python") + plugins::core::python::python_path(tv) .to_string_lossy() .to_string() }); diff --git a/src/plugins/core/mod.rs b/src/plugins/core/mod.rs index ef1c23c0cc..6901d871b8 100644 --- a/src/plugins/core/mod.rs +++ b/src/plugins/core/mod.rs @@ -18,7 +18,7 @@ mod erlang; mod go; mod java; mod node; -mod python; +pub(crate) mod python; #[cfg_attr(windows, path = "ruby_windows.rs")] mod ruby; mod rust; diff --git a/src/plugins/core/python.rs b/src/plugins/core/python.rs index b1e3f1b700..1ac097d19e 100644 --- a/src/plugins/core/python.rs +++ b/src/plugins/core/python.rs @@ -27,6 +27,14 @@ pub struct PythonPlugin { ba: BackendArg, } +pub fn python_path(tv: &ToolVersion) -> PathBuf { + if cfg!(windows) { + tv.install_path().join("python.exe") + } else { + tv.install_path().join("bin/python") + } +} + impl PythonPlugin { pub fn new() -> Self { let ba = plugins::core::new_backend_arg("python"); @@ -72,14 +80,6 @@ impl PythonPlugin { Ok(()) } - fn python_path(&self, tv: &ToolVersion) -> PathBuf { - if cfg!(windows) { - tv.install_path().join("python.exe") - } else { - tv.install_path().join("bin/python") - } - } - fn fetch_precompiled_remote_versions(&self) -> eyre::Result<&Vec<(String, String, String)>> { static PRECOMPILED_CACHE: Lazy>> = Lazy::new(|| { @@ -322,7 +322,7 @@ impl PythonPlugin { if !virtualenv.exists() { if SETTINGS.python.venv_auto_create { info!("setting up virtualenv at: {}", virtualenv.display()); - let mut cmd = CmdLineRunner::new(self.python_path(tv)) + let mut cmd = CmdLineRunner::new(python_path(tv)) .arg("-m") .arg("venv") .arg(&virtualenv) @@ -351,7 +351,7 @@ impl PythonPlugin { // fn check_venv_python(&self, virtualenv: &Path, tv: &ToolVersion) -> eyre::Result<()> { // let symlink = virtualenv.join("bin/python"); - // let target = self.python_path(tv); + // let target = python_path(tv); // let symlink_target = symlink.read_link().unwrap_or_default(); // ensure!( // symlink_target == target, @@ -370,7 +370,7 @@ impl PythonPlugin { pr: &Box, ) -> eyre::Result<()> { pr.set_message("python --version".into()); - CmdLineRunner::new(self.python_path(tv)) + CmdLineRunner::new(python_path(tv)) .with_pr(pr) .arg("--version") .envs(config.env()?)