diff --git a/.github/workflows/build_test_cbsinit.yml b/.github/workflows/build_test_cbsinit.yml index 88258c05..e6ab6b86 100644 --- a/.github/workflows/build_test_cbsinit.yml +++ b/.github/workflows/build_test_cbsinit.yml @@ -10,7 +10,7 @@ jobs: matrix: os: ['windows-2022'] download_official_python_msi: ["true"] - remove_python_pycs: ["true"] + remove_python_pycs: ["false"] install_with_pymanager: ["true"] cbsinit_repo: ['https://github.com/cloudbase/cloudbase-init'] cbsinit_branch: ['master'] @@ -101,7 +101,7 @@ jobs: } } & $pythonPath -m pip install pip-audit - $pipAuditLogs = & $pipAuditPath + $pipAuditLogs = & $pipAuditPath --user Write-Output "$pipAuditLogs" if ($LASTEXITCODE) { throw "pip audit failed" diff --git a/BuildAutomation/BuildCloudbaseInitSetup.ps1 b/BuildAutomation/BuildCloudbaseInitSetup.ps1 index a69d9a34..870cb795 100644 --- a/BuildAutomation/BuildCloudbaseInitSetup.ps1 +++ b/BuildAutomation/BuildCloudbaseInitSetup.ps1 @@ -97,6 +97,15 @@ try CheckCopyDir $python_template_dir $python_dir + $pythonGetPipUrl = "https://bootstrap.pypa.io/get-pip.py" + $pythonGetPipPath = Join-Path (Resolve-Path "${python_dir}/..").Path "/get-pip.py" + ExecRetry { DownloadFile $pythonGetPipUrl $pythonGetPipPath } + + & python.exe "${pythonGetPipPath}" + if ($LASTEXITCODE) { + throw "Failed to install pip in directory: ${python_dir}" + } + # Make sure that we don't have temp files from a previous build $python_build_path = "$ENV:LOCALAPPDATA\Temp\pip_build_$ENV:USERNAME" if (Test-Path $python_build_path) { @@ -104,6 +113,11 @@ try } ExecRetry { PipInstall "pip" -update $true } + # When using embed Python, pbr needs to be reinstalled so that the project builds + # Warning received: UserWarning: Unknown distribution option: 'pbr' + # pbr is already installed but most likely this is a problem with knowing where it is, + # and reinstalling fixing the issue + ExecRetry { PipInstall "pbr" -update $true } ExecRetry { PipInstall "wheel" -update $true } ExecRetry { PipInstall "setuptools" -update $true } diff --git a/BuildAutomation/BuildUtils.ps1 b/BuildAutomation/BuildUtils.ps1 index a9c3f13e..405b3ec2 100644 --- a/BuildAutomation/BuildUtils.ps1 +++ b/BuildAutomation/BuildUtils.ps1 @@ -484,7 +484,7 @@ function DownloadInstall-PythonUsingPyManager($platform, $python_template_dir, $ throw "$python_template_dir folder already exists" } - $pythonVersionEscaped = $pythonVersion.replace("_",".") + $platformSuffix + $pythonVersionEscaped = "PythonEmbed\" + $pythonVersion.replace("_",".") + $platformSuffix pymanager.exe install --target=$python_template_dir --force --update $pythonVersionEscaped if ($LASTEXITCODE) { throw "Failed to install python in directory: ${python_template_dir}" @@ -499,12 +499,38 @@ function DownloadInstall-PythonUsingPyManager($platform, $python_template_dir, $ throw "Failed to run python in directory: ${python_template_dir}" } - Remove-Item -Force -Recurse "$python_template_dir/DLLs/_tkinter.pyd" - Remove-Item -Force -Recurse "$python_template_dir/DLLs/tcl*.dll" - Remove-Item -Force -Recurse "$python_template_dir/DLLs/tk*.dll" - Remove-Item -Force -Recurse "$python_template_dir/Doc" - Remove-Item -Force -Recurse "$python_template_dir/Lib/tkinter" - Remove-Item -Force -Recurse "$python_template_dir/Lib/turtle.py" - Remove-Item -Force -Recurse "$python_template_dir/Lib/turtledemo" - Remove-Item -Force -Recurse "$python_template_dir/tcl" -} \ No newline at end of file + Out-File -Append -InputObject "Lib\site-packages" -Encoding ascii $python_template_dir\python*._pth + Out-File -Append -InputObject "libs" -Encoding ascii $python_template_dir\python*._pth + + $python_template_dir_full = $python_template_dir + "_full" + $pythonVersionEscaped = $pythonVersion.replace("_",".") + $platformSuffix + pymanager.exe install --target=$python_template_dir_full --force --update $pythonVersionEscaped + if ($LASTEXITCODE) { + throw "Failed to install python in directory: ${python_template_dir_full}" + } + + Move-Item $python_template_dir_full/include $python_template_dir/ + Move-Item $python_template_dir_full/libs $python_template_dir/ + + mkdir $python_template_dir\Lib\site-packages + + Out-File -Append -InputObject "win32" -Encoding ascii "$python_template_dir\Lib\site-packages\pywin32.pth" + Out-File -Append -InputObject "win32\lib" -Encoding ascii "$python_template_dir\Lib\site-packages\pywin32.pth" + Out-File -Append -InputObject "Pythonwin" -Encoding ascii "$python_template_dir\Lib\site-packages\pywin32.pth" + Out-File -Append -InputObject "import pywin32_bootstrap" -Encoding ascii "$python_template_dir\Lib\site-packages\pywin32.pth" + + Out-File -Append -InputObject "Lib\site-packages\win32" -Encoding ascii $python_template_dir\python*._pth + Out-File -Append -InputObject "Lib\site-packages\win32\lib" -Encoding ascii $python_template_dir\python*._pth + Out-File -Append -InputObject "Lib\site-packages\Pythonwin" -Encoding ascii $python_template_dir\python*._pth + + Remove-Item -Force -Recurse "$python_template_dir_full" -ErrorAction SilentlyContinue + + Remove-Item -Force -Recurse "$python_template_dir/DLLs/_tkinter.pyd" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/DLLs/tcl*.dll" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/DLLs/tk*.dll" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/Doc" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/Lib/tkinter" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/Lib/turtle.py" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/Lib/turtledemo" -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse "$python_template_dir/tcl" -ErrorAction SilentlyContinue +}