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
24 changes: 23 additions & 1 deletion builders/macos-python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ class macOSPythonBuilder : NixPythonBuilder {
return $pkgLocation
}

[bool] PkgExists() {
<#
.SYNOPSIS
Checks if the Universal Pkg Uri actually exists.
#>
$pkgUri = $this.GetPkgUri()

try {
$statusCode = (Invoke-WebRequest -Uri $pkgUri -UseBasicParsing -DisableKeepAlive -Method head).StatusCode
if ($statusCode -eq 200) {
return $true
} else {
Write-Host "File at $pkgUri did not appear to be valid, with status code '$statusCode'"
return $false;
}
} catch {
$statusCode = [int]$_.Exception.Response.StatusCode
Write-Host "File at $pkgUri did not appear to be valid, with status code '$statusCode'"
return $false
}
}

[void] CreateInstallationScriptPkg() {
<#
.SYNOPSIS
Expand Down Expand Up @@ -180,7 +202,7 @@ class macOSPythonBuilder : NixPythonBuilder {

$PkgVersion = [semver]"3.11.0-beta.1"

if (($this.Version -ge $PkgVersion) -or ($this.Architecture -eq "arm64")) {
if ((($this.Version -ge $PkgVersion) -or ($this.Architecture -eq "arm64")) -and ($this.PkgExists())) {
Write-Host "Download Python $($this.Version) [$($this.Architecture)] package..."
$this.DownloadPkg()

Expand Down
38 changes: 32 additions & 6 deletions builders/win-python-builder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ class WinPythonBuilder : PythonBuilder {
return $uri
}

[bool] PkgExists() {
<#
.SYNOPSIS
Checks if the Universal Pkg Uri actually exists.
#>
$pkgUri = $this.GetSourceUri()

try {
$statusCode = (Invoke-WebRequest -Uri $pkgUri -UseBasicParsing -DisableKeepAlive -Method head).StatusCode
if ($statusCode -eq 200) {
return $true
} else {
Write-Host "File at $pkgUri did not appear to be valid, with status code '$statusCode'"
return $false;
}
} catch {
$statusCode = [int]$_.Exception.Response.StatusCode
Write-Host "File at $pkgUri did not appear to be valid, with status code '$statusCode'"
return $false
}
}

[string] Download() {
<#
.SYNOPSIS
Expand Down Expand Up @@ -131,13 +153,17 @@ class WinPythonBuilder : PythonBuilder {
Generates Python artifact from downloaded Python installation executable.
#>

Write-Host "Download Python $($this.Version) [$($this.Architecture)] executable..."
$this.Download()
if ($this.PkgExists()) {
Write-Host "Download Python $($this.Version) [$($this.Architecture)] executable..."
$this.Download()

Write-Host "Create installation script..."
$this.CreateInstallationScript()
Write-Host "Create installation script..."
$this.CreateInstallationScript()

Write-Host "Archive artifact"
$this.ArchiveArtifact()
Write-Host "Archive artifact"
$this.ArchiveArtifact()
} else {
Write-Host "No source URI can be found"
}
}
}