Skip to content

Commit 0d6f9a7

Browse files
Copilotbytemain
andauthored
Clarify Windows pip shim assumptions
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 a13adf5 commit 0d6f9a7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

lib/util.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +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.
2425
local WINDOWS_PIP_SHIM_CONTENT = "@echo off\r\n\"%~dp0..\\python.exe\" -m pip %*\r\n"
2526

2627
local UV_BUILD_ENV = "VFOX_PYTHON_USE_UV_BUILD"
@@ -591,15 +592,14 @@ end
591592

592593
local function createWindowsPipShim(installPath, version)
593594
local major, minor = string.match(version, "^(%d+)%.(%d+)")
595+
if major == nil or minor == nil then
596+
error("Cannot create pip shim for unexpected Python version: " .. version)
597+
end
594598
local scriptsPath = installPath .. "\\Scripts"
595599
ensureWindowsDirectory(scriptsPath)
596600

597601
local shims = { "pip.cmd", "pip3.cmd" }
598-
if major ~= nil and minor ~= nil then
599-
table.insert(shims, "pip" .. major .. "." .. minor .. ".cmd")
600-
else
601-
print("Warning: unable to create versioned pip shim for unexpected Python version: " .. version)
602-
end
602+
table.insert(shims, "pip" .. major .. "." .. minor .. ".cmd")
603603
for _, shim in ipairs(shims) do
604604
writeWindowsFile(scriptsPath .. "\\" .. shim, WINDOWS_PIP_SHIM_CONTENT)
605605
end
@@ -614,6 +614,7 @@ local function ensureWindowsUvBuildPip(path, version)
614614
if not pathExists(pythonExe) then
615615
error("Cannot install pip: python.exe was not found at " .. pythonExe)
616616
end
617+
-- If Scripts does not exist yet, pathExists returns false and setup continues.
617618
if pathExists(path .. "\\Scripts\\pip.exe") or pathExists(path .. "\\Scripts\\pip.cmd") then
618619
return
619620
end

0 commit comments

Comments
 (0)