From f96a31855fa8aea55599cea412fe611b85a874ed Mon Sep 17 00:00:00 2001 From: Inhyuk Cho Date: Tue, 9 Jul 2024 21:46:42 +0900 Subject: fix(pypi): prefer stock python3 if it satisfies version requirement (#1736) --- lua/mason-core/installer/managers/pypi.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lua/mason-core') diff --git a/lua/mason-core/installer/managers/pypi.lua b/lua/mason-core/installer/managers/pypi.lua index 8dab25d9..f60a8ede 100644 --- a/lua/mason-core/installer/managers/pypi.lua +++ b/lua/mason-core/installer/managers/pypi.lua @@ -85,8 +85,10 @@ local function create_venv(pkg) -- 2. Resolve suitable versioned python3 installation (python3.12, python3.11, etc.). local versioned_candidates = {} if supported_python_versions ~= nil then - log.fmt_debug("Finding versioned candidates for %s", supported_python_versions) - versioned_candidates = get_versioned_candidates(supported_python_versions) + if stock_target and not pep440_check_version(tostring(stock_target.version), supported_python_versions) then + log.fmt_debug("Finding versioned candidates for %s", supported_python_versions) + versioned_candidates = get_versioned_candidates(supported_python_versions) + end end local target = resolve_python3(versioned_candidates) or stock_target -- cgit v1.2.3-70-g09d2