Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build_test_cbsinit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
os: ['windows-2022']
download_official_python_msi: ["true"]
remove_python_pycs: ["true"]
install_with_pymanager: ["true"]
cbsinit_repo: ['https://github.com/cloudbase/cloudbase-init']
cbsinit_branch: ['master']
python_version: ['3.14_4']
Expand All @@ -34,10 +35,11 @@ jobs:
-CloudbaseInitRepoBranch ${{ matrix.cbsinit_branch }} ^
-InstallOfficialPythonMsi:$${{ matrix.download_official_python_msi }} ^
-OfficialPythonMsiChecksum "C10234D0D9BD89F6F6DD55BAE28EDE0F97EE0DF4" ^
-RemovePythonPycs:$${{ matrix.remove_python_pycs }}
-RemovePythonPycs:$${{ matrix.remove_python_pycs }} ^
-InstallOfficialPythonUsingPyManager:$${{ matrix.install_with_pymanager }}
- uses: actions/upload-artifact@v7
with:
name: "CloudbaseInit_platform-${{ matrix.platform }}_build-env-os-${{ matrix.os }}_download-official-msi-${{ matrix.download_official_python_msi }}_remove-pycs-${{ matrix.remove_python_pycs }}_cbs-init-branch-${{ matrix.cbsinit_branch }}_MSI"
name: "CloudbaseInit_platform-${{ matrix.platform }}_build-env-os-${{ matrix.os }}_download-official-msi-${{ matrix.download_official_python_msi }}_remove-pycs-${{ matrix.remove_python_pycs }}_install-with-pymanager${{ matrix.install_with_pymanager }}_cbs-init-branch-${{ matrix.cbsinit_branch }}_MSI"
path: 'CloudbaseInitSetup/bin/release/${{ matrix.platform }}/CloudbaseInitSetup.msi'
- name: Download external dependencies
shell: powershell
Expand Down
17 changes: 12 additions & 5 deletions BuildAutomation/BuildCloudbaseInitSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Param(
[string]$VCVars = "2019",
[switch]$InstallOfficialPythonMsi = $false,
[string]$OfficialPythonMsiChecksum = "C10234D0D9BD89F6F6DD55BAE28EDE0F97EE0DF4",
[switch]$RemovePythonPycs = $false
[switch]$RemovePythonPycs = $false,
[switch]$InstallOfficialPythonUsingPyManager = $false
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -80,12 +81,18 @@ try

$python_template_dir = join-path $cloudbaseInitInstallerDir "Python$($pythonversion.replace('.', ''))_${platform}_Template"

# TODO(avladu): stick to just only one way to download Python, preferably the pymanager once it gets ironed out
if ($InstallOfficialPythonMsi) {
if (!$OfficialPythonMsiChecksum) {
throw "Please set a OfficialPythonMsiChecksum parameter value."
if ($InstallOfficialPythonUsingPyManager) {
Comment thread
ader1990 marked this conversation as resolved.
Remove-Item -Recurse -Force $python_template_dir -ErrorAction SilentlyContinue
DownloadInstall-PythonUsingPyManager $platform $python_template_dir $pythonversion
} else {
if (!$OfficialPythonMsiChecksum) {
throw "Please set a OfficialPythonMsiChecksum parameter value."
}
Remove-Item -Recurse -Force $python_template_dir -ErrorAction SilentlyContinue
DownloadInstall-PythonMsi $platform $python_template_dir $pythonversion $OfficialPythonMsiChecksum
}
Remove-Item -Recurse -Force $python_template_dir -ErrorAction SilentlyContinue
DownloadInstall-PythonMsi $platform $python_template_dir $pythonversion $OfficialPythonMsiChecksum
}

CheckCopyDir $python_template_dir $python_dir
Expand Down
48 changes: 48 additions & 0 deletions BuildAutomation/BuildUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,51 @@ function DownloadInstall-PythonMsi($platform, $python_template_dir, $pythonVersi
}

}

function DownloadInstall-PythonUsingPyManager($platform, $python_template_dir, $pythonVersion) {
$pythonManagerUrl = "https://www.python.org/ftp/python/pymanager/python-manager-26.1.msix"
$pythonManagerPath = Join-Path (Resolve-Path "${python_template_dir}/..").Path "/python-manager.exe"

$pythonManagerPackage = Get-AppPackage -Name PythonSoftwareFoundation.PythonManager -ErrorAction SilentlyContinue

if (!$pythonManagerPackage) {
ExecRetry { DownloadFile $pythonManagerUrl $pythonManagerPath }
Add-AppPackage -Path $pythonManagerPath
}

$platformSuffix = ""
if ($platform -eq "x86") {
$platformSuffix = "-32"
}
if ($platform -eq "arm64") {
$platformSuffix = "-arm64"
}

if (Test-Path $python_template_dir) {
throw "$python_template_dir folder already exists"
}

$pythonVersionEscaped = $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}"
}

if (!(Test-Path $python_template_dir)) {
throw "$python_template_dir has not been created"
}

& "$python_template_dir/python.exe" --version
if ($LASTEXITCODE) {
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"
}