From 159c570b13a23d429a3d020eda488ced0fa13572 Mon Sep 17 00:00:00 2001 From: Simon Holloway Date: Thu, 19 Dec 2024 01:25:07 +0000 Subject: [PATCH 1/3] fix: create venv uses absolute tool paths --- src/config/env_directive/venv.rs | 66 +++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/src/config/env_directive/venv.rs b/src/config/env_directive/venv.rs index 93507d57a0..2b6e4de42b 100644 --- a/src/config/env_directive/venv.rs +++ b/src/config/env_directive/venv.rs @@ -38,19 +38,24 @@ impl EnvResults { let config = Config::get(); let ts = ToolsetBuilder::new().build(&config)?; let ba = BackendArg::from("python"); - let installed = ts - .versions - .get(&ba) - .and_then(|tv| { - // if a python version is specified, check if that version is installed - // otherwise use the first since that's what `python3` will refer to - if let Some(v) = &python { - tv.versions.iter().find(|t| t.version.starts_with(v)) - } else { - tv.versions.first() - } - }) - .map(|tv| { + let tv = ts.versions.get(&ba).and_then(|tv| { + // if a python version is specified, check if that version is installed + // otherwise use the first since that's what `python3` will refer to + if let Some(v) = &python { + tv.versions.iter().find(|t| t.version.starts_with(v)) + } else { + tv.versions.first() + } + }); + let python_path = tv.map(|tv| { + tv.install_path() + .join("bin") + .join("python") + .to_string_lossy() + .to_string() + }); + let installed = tv + .map(|tv: &crate::toolset::ToolVersion| { let backend = backend::get(&ba).unwrap(); backend.is_version_installed(tv, false) }) @@ -59,12 +64,12 @@ impl EnvResults { .unwrap_or(true); if !installed { warn!( - "no venv found at: {p}\n\n\ - mise will automatically create the venv once all requested python versions are installed.\n\ - To install the missing python versions and create the venv, please run:\n\ - mise install", - p = display_path(&venv) - ); + "no venv found at: {p}\n\n\ + mise will automatically create the venv once all requested python versions are installed.\n\ + To install the missing python versions and create the venv, please run:\n\ + mise install", + p = display_path(&venv) + ); } else { let has_uv_bin = ts.which("uv").is_some() || which_non_pristine("uv").is_some(); let use_uv = !SETTINGS.python.venv_stdlib && has_uv_bin; @@ -84,9 +89,15 @@ impl EnvResults { .or(uv_create_args) .unwrap_or_default(); let mut cmd = CmdLineRunner::new("uv").args(["venv", &venv.to_string_lossy()]); - if let Some(python) = python { - cmd = cmd.args(["--python", &python]); - } + + cmd = match (python_path, python) { + // The selected mise managed python tool path from env._.python.venv.python or first in list + (Some(python_path), _) => cmd.args(["--python", &python_path]), + // User specified in env._.python.venv.python but it's not in mise tools, so pass version number to uv + (_, Some(python)) => cmd.args(["--python", &python]), + // Default to whatever uv wants to use + _ => cmd, + }; cmd.args(extra) } else { info!("creating venv with stdlib at: {}", display_path(&venv)); @@ -103,7 +114,16 @@ impl EnvResults { }) .or(python_create_args) .unwrap_or_default(); - let bin = format!("python{}", python.unwrap_or("3".into())); + + let bin = match (python_path, python) { + // The selected mise managed python tool path from env._.python.venv.python or first in list + (Some(python_path), _) => python_path, + // User specified in env._.python.venv.python but it's not in mise tools, so try to find it on path + (_, Some(python)) => format!("python{}", python), + // Default to whatever python3 points to on path + _ => "python3".to_string(), + }; + CmdLineRunner::new(bin) .args(["-m", "venv", &venv.to_string_lossy()]) .args(extra) From 6854724ca1de646baabe3420b84ece797a6fa6af Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:35:23 +0000 Subject: [PATCH 2/3] [autofix.ci] apply automated fixes --- tasks.md | 32 -------------------------------- tasks.toml | 10 +++++----- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/tasks.md b/tasks.md index a34de1efff..2ed0223686 100644 --- a/tasks.md +++ b/tasks.md @@ -17,38 +17,6 @@ - **Usage**: `clean` -## `docker:cargo` - -- **Usage**: `docker:cargo` - -run cargo inside of development docker container - -## `docker:e2e` - -- **Usage**: `docker:e2e` - -run e2e tests inside of development docker container - -## `docker:image` - -- **Usage**: `docker:image` - -build docker image from Dockerfile - -## `docker:mise` - -- **Usage**: `docker:mise` - -run mise inside of development docker container - -## `docker:run` - -- Depends: docker:image - -- **Usage**: `docker:run` - -run a command inside of development docker container - ## `docs` - Depends: docs:setup diff --git a/tasks.toml b/tasks.toml index 02a98244b3..ceb03560ec 100644 --- a/tasks.toml +++ b/tasks.toml @@ -101,28 +101,28 @@ run = "cargo test --all-features" env = { CARGO_TERM_COLOR = "always", "RUST_TEST_THREADS" = "1" } ["docker:image"] -hide = true # docker stuff is not working correctly right now +hide = true # docker stuff is not working correctly right now description = "build docker image from Dockerfile" run = 'docker build --build-arg GITHUB_TOKEN=$GITHUB_API_TOKEN $root -f $root/packaging/dev/Dockerfile -t ghcr.io/jdx/mise:dev' ["docker:run"] -hide = true # docker stuff is not working correctly right now +hide = true # docker stuff is not working correctly right now description = "run a command inside of development docker container" run = 'docker run -ti --rm -e GITHUB_API_TOKEN -e TEST_ALL -v $root:/mise -v /tmp/mise/target:/tmp/mise/target -v /tmp/mise/registry:/tmp/mise/registry -w /mise ghcr.io/jdx/mise:dev' depends = ["docker:image"] ["docker:cargo"] -hide = true # docker stuff is not working correctly right now +hide = true # docker stuff is not working correctly right now description = "run cargo inside of development docker container" run = 'mise tasks run docker:run cargo' ["docker:mise"] -hide = true # docker stuff is not working correctly right now +hide = true # docker stuff is not working correctly right now description = "run mise inside of development docker container" run = "mise tasks run -- docker:cargo run --" ["docker:e2e"] -hide = true # docker stuff is not working correctly right now +hide = true # docker stuff is not working correctly right now description = "run e2e tests inside of development docker container" run = "mise tasks run docker:mise run test:e2e" From 3b78b1821f9bccaa17ea7f24cae8bb7b221bf218 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:46:21 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- registry.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry.toml b/registry.toml index 67a606e0b0..0e1ec6f4a2 100644 --- a/registry.toml +++ b/registry.toml @@ -383,7 +383,7 @@ concourse.backends = [ "asdf:mattysweeps/asdf-concourse" ] conduit.backends = ["ubi:ConduitIO/conduit", "asdf:gmcabrita/asdf-conduit"] -conduit.test = ["conduit --version", "v{{version}}"] +conduit.test = ["conduit --version", "v{{version}}"] conform.backends = ["aqua:siderolabs/conform", "asdf:skyzyx/asdf-conform"] conform.os = ["linux", "macos"] conform.test = ["conform version", "conform version v{{version}}"]