Skip to content

Commit

Permalink
fix: venv dir can stay venv
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMichaelPark committed Oct 25, 2024
1 parent f20ef6c commit 20a3341
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions lua/mason-core/installer/managers/pypi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ local spawn = require "mason-core.spawn"
local M = {}

local use_uv = settings.current.pip.use_uv
local VENV_DIR
if use_uv then
VENV_DIR = ".venv"
else
VENV_DIR = "venv"
end
VENV_DIR = "venv"

---@async
---@param candidates string[]
Expand Down Expand Up @@ -77,10 +72,10 @@ local function get_versioned_candidates(supported_python_versions)
{ semver.new "3.12.0", "python3.12" },
{ semver.new "3.11.0", "python3.11" },
{ semver.new "3.10.0", "python3.10" },
{ semver.new "3.9.0", "python3.9" },
{ semver.new "3.8.0", "python3.8" },
{ semver.new "3.7.0", "python3.7" },
{ semver.new "3.6.0", "python3.6" },
{ semver.new "3.9.0", "python3.9" },
{ semver.new "3.8.0", "python3.8" },
{ semver.new "3.7.0", "python3.7" },
{ semver.new "3.6.0", "python3.6" },
})
end

Expand Down Expand Up @@ -126,15 +121,17 @@ local function create_venv(pkg)
then
if ctx.opts.force then
ctx.stdio_sink.stderr(
("Warning: The resolved python3 version %s is not compatible with the required Python versions: %s.\n"):format(
("Warning: The resolved python3 version %s is not compatible with the required Python versions: %s.\n")
:format(
target.version,
supported_python_versions
)
)
else
ctx.stdio_sink.stderr "Run with :MasonInstall --force to bypass this version validation.\n"
return Result.failure(
("Failed to find a python3 installation in PATH that meets the required versions (%s). Found version: %s."):format(
("Failed to find a python3 installation in PATH that meets the required versions (%s). Found version: %s.")
:format(
supported_python_versions,
target.version
)
Expand Down Expand Up @@ -176,7 +173,7 @@ end
local function venv_python(args)
local ctx = installer.context()
if use_uv then
return ctx.spawn[{ "uv", "venv" }](args)
return ctx.spawn["uv"](args)
end
return find_venv_executable(ctx, "python"):and_then(function(python_path)
return ctx.spawn[path.concat { ctx.cwd:get(), python_path }](args)
Expand All @@ -188,16 +185,15 @@ end
---@param extra_args? string[]
local function pip_install(pkgs, extra_args)
if use_uv then
local ctx = installer.context()

local task = ctx.spawn["uv"] {
return venv_python {
"pip",
"install",
"--directory",
"venv",
"-U",
extra_args or vim.NIL,
pkgs,
}
return task
else
return venv_python {
"-m",
Expand Down

0 comments on commit 20a3341

Please sign in to comment.