@@ -570,7 +570,39 @@ local function pathExists(path)
570570 return false
571571end
572572
573- local function ensureWindowsUvBuildPip (path )
573+ local function ensureWindowsDirectory (path )
574+ local command = powerShellCommand (" New-Item -ItemType Directory -Force -Path " .. powerShellQuote (path ) .. " | Out-Null" )
575+ local exitCode = os.execute (command )
576+ if not commandSucceeded (exitCode ) then
577+ error (" Failed to create directory: " .. path .. " . Exit code: " .. tostring (exitCode ))
578+ end
579+ end
580+
581+ local function writeWindowsFile (path , content )
582+ local file = io.open (path , " w" )
583+ if not file then
584+ error (" Failed to write file: " .. path )
585+ end
586+ file :write (content )
587+ file :close ()
588+ end
589+
590+ local function createWindowsPipShim (installPath , version )
591+ local major , minor = string.match (version , " ^(%d+)%.(%d+)" )
592+ local scriptsPath = installPath .. " \\ Scripts"
593+ ensureWindowsDirectory (scriptsPath )
594+
595+ local content = " @echo off\r\n\" %~dp0..\\ python.exe\" -m pip %*\r\n "
596+ local shims = { " pip.cmd" , " pip3.cmd" }
597+ if major ~= nil and minor ~= nil then
598+ table.insert (shims , " pip" .. major .. " ." .. minor .. " .cmd" )
599+ end
600+ for _ , shim in ipairs (shims ) do
601+ writeWindowsFile (scriptsPath .. " \\ " .. shim , content )
602+ end
603+ end
604+
605+ local function ensureWindowsUvBuildPip (path , version )
574606 if runtimeOs () ~= " windows" then
575607 return
576608 end
@@ -579,7 +611,7 @@ local function ensureWindowsUvBuildPip(path)
579611 if not pathExists (pythonExe ) then
580612 error (" Cannot install pip: python.exe was not found at " .. pythonExe )
581613 end
582- if pathExists (path .. " \\ Scripts\\ pip.exe" ) then
614+ if pathExists (path .. " \\ Scripts\\ pip.exe" ) or pathExists ( path .. " \\ Scripts \\ pip.cmd " ) then
583615 return
584616 end
585617
@@ -609,8 +641,14 @@ local function ensureWindowsUvBuildPip(path)
609641 error (" pip force-reinstall failed while creating pip scripts. Exit code: " .. tostring (exitCode ))
610642 end
611643
644+ command = powerShellPythonCommand (pythonExe , { " -E" , " -s" , " -m" , " pip" , " --version" })
645+ exitCode = os.execute (command )
646+ if not commandSucceeded (exitCode ) then
647+ error (" pip module is not available after installation attempts. Exit code: " .. tostring (exitCode ))
648+ end
649+
612650 if not pathExists (path .. " \\ Scripts\\ pip.exe" ) then
613- error ( " Failed to install pip: pip.exe was not created after installation attempts " )
651+ createWindowsPipShim ( path , version )
614652 end
615653end
616654
@@ -709,7 +747,7 @@ function uvBuildInstall(ctx)
709747 if OS_TYPE ~= " windows" then
710748 fixShebangLines (extractedPath )
711749 else
712- ensureWindowsUvBuildPip (extractedPath )
750+ ensureWindowsUvBuildPip (extractedPath , version )
713751 end
714752
715753 print (" Install Python uv-build success!" )
0 commit comments