Skip to content

Commit be09f06

Browse files
committed
feat(pypi): add setting to respect g:python3_host_prog if set
1 parent 8024d64 commit be09f06

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

lua/mason-core/installer/managers/pypi.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ local pep440 = require "mason-core.pep440"
99
local platform = require "mason-core.platform"
1010
local providers = require "mason-core.providers"
1111
local semver = require "mason-core.semver"
12+
local settings = require "mason.settings"
1213
local spawn = require "mason-core.spawn"
1314

1415
local M = {}
@@ -85,6 +86,9 @@ local function create_venv(pkg)
8586

8687
-- 1. Resolve stock python3 installation.
8788
local stock_candidates = platform.is.win and { "python", "python3" } or { "python3", "python" }
89+
if settings.current.pip.use_python3_host_prog and vim.g.python3_host_prog then
90+
table.insert(stock_candidates, 1, vim.g.python3_host_prog)
91+
end
8892
local stock_target = resolve_python3(stock_candidates)
8993
if stock_target then
9094
log.fmt_debug("Resolved stock python3 installation version %s", stock_target.version)

lua/mason/health.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ local function check_languages()
214214
check_thunk { cmd = "julia", args = { "--version" }, name = "julia", relaxed = true },
215215
function()
216216
local python = platform.is.win and "python" or "python3"
217+
if settings.current.pip.use_python3_host_prog and vim.g.python3_host_prog then
218+
python = vim.g.python3_host_prog
219+
end
217220
check { cmd = python, args = { "--version" }, name = "python", relaxed = true }
218221
check { cmd = python, args = { "-m", "pip", "--version" }, name = "pip", relaxed = true }
219222
check {

lua/mason/settings.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ local DEFAULT_SETTINGS = {
6666
--
6767
-- Example: { "--proxy", "https://proxyserver" }
6868
install_args = {},
69+
70+
---@since 2.0.1
71+
-- Respect the `vim.g.python3_host_prog` while resolving packages from PyPI
72+
use_python3_host_prog = false,
6973
},
7074

7175
ui = {

0 commit comments

Comments
 (0)