Skip to content

Commit a13adf5

Browse files
Copilotbytemain
andauthored
Polish Windows pip shim diagnostics
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 21052d3 commit a13adf5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/util.lua

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

24+
local WINDOWS_PIP_SHIM_CONTENT = "@echo off\r\n\"%~dp0..\\python.exe\" -m pip %*\r\n"
25+
2426
local UV_BUILD_ENV = "VFOX_PYTHON_USE_UV_BUILD"
2527
local UV_BUILD_MIRROR_ENV = "VFOX_PYTHON_UV_BUILD_MIRROR"
2628

@@ -574,7 +576,7 @@ local function ensureWindowsDirectory(path)
574576
local command = powerShellCommand("New-Item -ItemType Directory -Force -Path " .. powerShellQuote(path) .. " | Out-Null")
575577
local exitCode = os.execute(command)
576578
if not commandSucceeded(exitCode) then
577-
error("Failed to create directory: " .. path .. ". Exit code: " .. tostring(exitCode))
579+
error("Failed to create directory: " .. path .. ". Command: " .. command .. ". Exit code: " .. tostring(exitCode))
578580
end
579581
end
580582

@@ -592,13 +594,14 @@ local function createWindowsPipShim(installPath, version)
592594
local scriptsPath = installPath .. "\\Scripts"
593595
ensureWindowsDirectory(scriptsPath)
594596

595-
local content = "@echo off\r\n\"%~dp0..\\python.exe\" -m pip %*\r\n"
596597
local shims = { "pip.cmd", "pip3.cmd" }
597598
if major ~= nil and minor ~= nil then
598599
table.insert(shims, "pip" .. major .. "." .. minor .. ".cmd")
600+
else
601+
print("Warning: unable to create versioned pip shim for unexpected Python version: " .. version)
599602
end
600603
for _, shim in ipairs(shims) do
601-
writeWindowsFile(scriptsPath .. "\\" .. shim, content)
604+
writeWindowsFile(scriptsPath .. "\\" .. shim, WINDOWS_PIP_SHIM_CONTENT)
602605
end
603606
end
604607

0 commit comments

Comments
 (0)