aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron U'Ren <aauren@users.noreply.github.com>2026-05-07 12:31:01 -0500
committerGitHub <noreply@github.com>2026-05-07 17:31:01 +0000
commite54f5bf5f12c560da31c17eee5b3e1bd369f3ff9 (patch)
treef7b4e188c82c5411c241ccf97ef71b4b25ae3f59
parentfix(spawn): handle cases where PATH env on Windows is not set (#2080) (diff)
downloadmason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.tar
mason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.tar.gz
mason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.tar.bz2
mason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.tar.lz
mason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.tar.xz
mason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.tar.zst
mason-e54f5bf5f12c560da31c17eee5b3e1bd369f3ff9.zip
fix(pypi): add python 3.13 and 3.14 to list of fallbacks (#2081)HEADmain
-rw-r--r--lua/mason-core/installer/managers/pypi.lua15
-rw-r--r--tests/mason-core/installer/managers/pypi_spec.lua43
2 files changed, 52 insertions, 6 deletions
diff --git a/lua/mason-core/installer/managers/pypi.lua b/lua/mason-core/installer/managers/pypi.lua
index 72b1b503..9b39b0d6 100644
--- a/lua/mason-core/installer/managers/pypi.lua
+++ b/lua/mason-core/installer/managers/pypi.lua
@@ -66,13 +66,16 @@ local function get_versioned_candidates(supported_python_versions)
end
return Optional.of(executable)
end, {
- { 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" },
+ -- IMPORTANT: should be in ASCENDING order
{ semver.new "3.6.0", "python3.6" },
+ { semver.new "3.7.0", "python3.7" },
+ { semver.new "3.8.0", "python3.8" },
+ { semver.new "3.9.0", "python3.9" },
+ { semver.new "3.10.0", "python3.10" },
+ { semver.new "3.11.0", "python3.11" },
+ { semver.new "3.12.0", "python3.12" },
+ { semver.new "3.13.0", "python3.13" },
+ { semver.new "3.14.0", "python3.14" },
})
end
diff --git a/tests/mason-core/installer/managers/pypi_spec.lua b/tests/mason-core/installer/managers/pypi_spec.lua
index ef57411b..2fdf0002 100644
--- a/tests/mason-core/installer/managers/pypi_spec.lua
+++ b/tests/mason-core/installer/managers/pypi_spec.lua
@@ -92,6 +92,8 @@ describe("pypi manager", function()
stub(ctx.fs, "file_exists")
stub(providers.pypi, "get_supported_python_versions", mockx.returns(Result.success ">=3.12"))
stub(vim.fn, "executable")
+ vim.fn.executable.on_call_with("python3.14").returns(0)
+ vim.fn.executable.on_call_with("python3.13").returns(0)
vim.fn.executable.on_call_with("python3.12").returns(1)
stub(spawn, "python3.12")
spawn["python3.12"].on_call_with({ "--version" }).returns(Result.success { stdout = "Python 3.12.0" })
@@ -115,6 +117,43 @@ describe("pypi manager", function()
}
end)
+ it("should find versioned candidates in ascending order", function()
+ local ctx = test_helpers.create_context()
+ stub(ctx, "promote_cwd")
+ stub(ctx.fs, "file_exists")
+ stub(providers.pypi, "get_supported_python_versions", mockx.returns(Result.success ">=3.12"))
+ stub(vim.fn, "executable")
+ vim.fn.executable.on_call_with("python3.14").returns(1)
+ vim.fn.executable.on_call_with("python3.13").returns(1)
+ vim.fn.executable.on_call_with("python3.12").returns(1)
+ stub(spawn, "python3.14")
+ stub(spawn, "python3.13")
+ stub(spawn, "python3.12")
+ spawn["python3.14"].on_call_with({ "--version" }).returns(Result.success { stdout = "Python 3.14.0" })
+ spawn["python3.13"].on_call_with({ "--version" }).returns(Result.success { stdout = "Python 3.13.0" })
+ spawn["python3.12"].on_call_with({ "--version" }).returns(Result.success { stdout = "Python 3.12.0" })
+ ctx.fs.file_exists.on_call_with(match.ref(ctx.fs), "venv/bin/python").returns(true)
+
+ ctx:execute(function()
+ pypi.init {
+ package = { name = "cmake-language-server", version = "0.1.10" },
+ upgrade_pip = false,
+ install_extra_args = {},
+ }
+ end)
+
+ assert.spy(ctx.spawn["python3.14"]).was_not_called()
+ assert.spy(ctx.spawn["python3.13"]).was_not_called()
+ assert.spy(ctx.promote_cwd).was_called(1)
+ assert.spy(ctx.spawn["python3.12"]).was_called(1)
+ assert.spy(ctx.spawn["python3.12"]).was_called_with {
+ "-m",
+ "venv",
+ "--system-site-packages",
+ "venv",
+ }
+ end)
+
it("should error if unable to find a suitable python3 version", function()
local ctx = test_helpers.create_context()
spy.on(ctx.stdio_sink, "stderr")
@@ -122,6 +161,8 @@ describe("pypi manager", function()
stub(ctx.fs, "file_exists")
stub(providers.pypi, "get_supported_python_versions", mockx.returns(Result.success ">=3.8"))
stub(vim.fn, "executable")
+ vim.fn.executable.on_call_with("python3.14").returns(0)
+ vim.fn.executable.on_call_with("python3.13").returns(0)
vim.fn.executable.on_call_with("python3.12").returns(0)
vim.fn.executable.on_call_with("python3.11").returns(0)
vim.fn.executable.on_call_with("python3.10").returns(0)
@@ -156,6 +197,8 @@ describe("pypi manager", function()
stub(ctx.fs, "file_exists")
stub(providers.pypi, "get_supported_python_versions", mockx.returns(Result.success ">=3.8"))
stub(vim.fn, "executable")
+ vim.fn.executable.on_call_with("python3.14").returns(0)
+ vim.fn.executable.on_call_with("python3.13").returns(0)
vim.fn.executable.on_call_with("python3.12").returns(0)
vim.fn.executable.on_call_with("python3.11").returns(0)
vim.fn.executable.on_call_with("python3.10").returns(0)