Skip to content

Commit 1d0d8ca

Browse files
Copilotbytemain
andauthored
Refine Windows pip shim checks
Agent-Logs-Url: https://github.com/version-fox/vfox-python/sessions/fab67593-0eb0-42b0-b32e-e6f9fe3bf105 Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 8a4222c commit 1d0d8ca

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lib/util.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ local REQUEST_HEADERS = {
2121
["User-Agent"] = "vfox"
2222
}
2323

24-
-- vfox adds both the install root and install root\Scripts to PATH on Windows.
24+
-- pip.cmd lives under Scripts, so %~dp0..\python.exe resolves to the install root's python.exe.
2525
local WINDOWS_PIP_SHIM_CONTENT = "@echo off\r\n\"%~dp0..\\python.exe\" -m pip %*\r\n"
2626

2727
local UV_BUILD_ENV = "VFOX_PYTHON_USE_UV_BUILD"
@@ -577,7 +577,7 @@ local function ensureWindowsDirectory(path)
577577
local command = powerShellCommand("New-Item -ItemType Directory -Force -Path " .. powerShellQuote(path) .. " | Out-Null")
578578
local exitCode = os.execute(command)
579579
if not commandSucceeded(exitCode) then
580-
error("Failed to create directory: " .. path .. ". Command: " .. command .. ". Exit code: " .. tostring(exitCode))
580+
error("Failed to create directory: " .. path .. ". Exit code: " .. tostring(exitCode))
581581
end
582582
end
583583

@@ -599,6 +599,10 @@ local function createWindowsPipShim(scriptsPath)
599599
end
600600
end
601601

602+
local function windowsPipCommandExists(scriptsPath)
603+
return pathExists(scriptsPath .. "\\pip.exe") or pathExists(scriptsPath .. "\\pip.cmd")
604+
end
605+
602606
local function ensureWindowsUvBuildPip(path)
603607
if runtimeOs() ~= "windows" then
604608
return
@@ -610,7 +614,7 @@ local function ensureWindowsUvBuildPip(path)
610614
error("Cannot install pip: python.exe was not found at " .. pythonExe)
611615
end
612616
-- If Scripts does not exist yet, pathExists returns false and setup continues.
613-
if pathExists(scriptsPath .. "\\pip.exe") or pathExists(scriptsPath .. "\\pip.cmd") then
617+
if windowsPipCommandExists(scriptsPath) then
614618
return
615619
end
616620

@@ -626,7 +630,7 @@ local function ensureWindowsUvBuildPip(path)
626630
error("ensurepip failed while installing pip. Exit code: " .. tostring(exitCode))
627631
end
628632

629-
if pathExists(scriptsPath .. "\\pip.exe") then
633+
if windowsPipCommandExists(scriptsPath) then
630634
return
631635
end
632636

@@ -646,7 +650,7 @@ local function ensureWindowsUvBuildPip(path)
646650
error("pip module is not available after installation attempts. Exit code: " .. tostring(exitCode))
647651
end
648652

649-
if not pathExists(scriptsPath .. "\\pip.exe") then
653+
if not windowsPipCommandExists(scriptsPath) then
650654
createWindowsPipShim(scriptsPath)
651655
end
652656
end

0 commit comments

Comments
 (0)