mirror of
https://github.com/actions/python-versions.git
synced 2025-12-16 07:46:47 +00:00
Compare commits
4 Commits
windows-ar
...
arm64win-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42cf8bab67 | ||
|
|
d3b7d73238 | ||
|
|
1d2e861434 | ||
|
|
d55f04f8e6 |
9
.github/workflows/build-python-packages.yml
vendored
9
.github/workflows/build-python-packages.yml
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
name: Build Python package
|
name: Build Python package
|
||||||
run-name: Generate Python ${{ inputs.VERSION || '3.12.3' }}
|
run-name: Generate Python ${{ inputs.VERSION || '3.12.3' }}
|
||||||
on:
|
on:
|
||||||
@@ -15,7 +16,7 @@ on:
|
|||||||
PLATFORMS:
|
PLATFORMS:
|
||||||
description: 'Platforms for execution in "os" or "os_arch" format (arch is "x64" by default)'
|
description: 'Platforms for execution in "os" or "os_arch" format (arch is "x64" by default)'
|
||||||
required: true
|
required: true
|
||||||
default: 'ubuntu-20.04,ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,macos-11_x64,macos-14_arm64,windows-2019_x64,windows-2019_x86,windows-2019_arm64'
|
default: 'ubuntu-20.04,ubuntu-20.04_arm64,ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,macos-11_x64,macos-14_arm64,windows-2019_x64,windows-2019_x86,windows-2019_arm64'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'versions-manifest.json'
|
- 'versions-manifest.json'
|
||||||
@@ -39,7 +40,7 @@ jobs:
|
|||||||
- name: Generate execution matrix
|
- name: Generate execution matrix
|
||||||
id: generate-matrix
|
id: generate-matrix
|
||||||
run: |
|
run: |
|
||||||
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-20.04,ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,macos-11,macos-14_arm64,windows-2019_x64,windows-2019_x86,windows-2019_arm64' }}".Split(",").Trim()
|
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-20.04,ubuntu-20.04_arm64,ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,macos-11,macos-14_arm64,windows-2019_x64,windows-2019_x86,windows-2019_arm64' }}".Split(",").Trim()
|
||||||
$matrix = @()
|
$matrix = @()
|
||||||
|
|
||||||
foreach ($configuration in $configurations) {
|
foreach ($configuration in $configurations) {
|
||||||
@@ -53,9 +54,7 @@ jobs:
|
|||||||
"*windows*" { $platform = 'win32' }
|
"*windows*" { $platform = 'win32' }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($configuration -eq "ubuntu-22.04_arm64") {
|
if ($configuration -eq "windows-2019_arm64") {
|
||||||
$os = "setup-actions-ubuntu-arm64-2-core"
|
|
||||||
}elseif ($configuration -eq "windows-2019_arm64") {
|
|
||||||
$os = "setup-actions-windows-arm64-4-core"
|
$os = "setup-actions-windows-arm64-4-core"
|
||||||
}
|
}
|
||||||
$matrix += @{
|
$matrix += @{
|
||||||
|
|||||||
169
builders/nix-python-builder.psm1
Normal file
169
builders/nix-python-builder.psm1
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
using module "./python-builder.psm1"
|
||||||
|
|
||||||
|
class NixPythonBuilder : PythonBuilder {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Base Python builder class for *Nix systems.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Contains methods that required to build Python artifact for *nix systems. Inherited from base PythonBuilder class.
|
||||||
|
|
||||||
|
.PARAMETER version
|
||||||
|
The version of Python that should be built.
|
||||||
|
|
||||||
|
.PARAMETER Platform
|
||||||
|
The type of platform for which Python should be built.
|
||||||
|
|
||||||
|
.PARAMETER PlatformVersion
|
||||||
|
The version of platform for which Python should be built.
|
||||||
|
|
||||||
|
.PARAMETER InstallationTemplateName
|
||||||
|
The name of template that will be used to create installation script for generated Python artifact.
|
||||||
|
|
||||||
|
.PARAMETER InstallationScriptName
|
||||||
|
The name of installation script that will be generated for Python artifact.
|
||||||
|
|
||||||
|
.PARAMETER OutputArtifactName
|
||||||
|
The name of archive with Python binaries that will be generated as part of Python artifact.
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
[string] $InstallationTemplateName
|
||||||
|
[string] $InstallationScriptName
|
||||||
|
[string] $OutputArtifactName
|
||||||
|
|
||||||
|
NixPythonBuilder(
|
||||||
|
[semver] $version,
|
||||||
|
[string] $architecture,
|
||||||
|
[string] $platform
|
||||||
|
) : Base($version, $architecture, $platform) {
|
||||||
|
$this.InstallationTemplateName = "nix-setup-template.sh"
|
||||||
|
$this.InstallationScriptName = "setup.sh"
|
||||||
|
$this.OutputArtifactName = "python-$Version-$Platform-$Architecture.tar.gz"
|
||||||
|
}
|
||||||
|
|
||||||
|
[uri] GetSourceUri() {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get base Python URI and return complete URI for Python sources.
|
||||||
|
#>
|
||||||
|
|
||||||
|
$base = $this.GetBaseUri()
|
||||||
|
$versionName = $this.GetBaseVersion()
|
||||||
|
$nativeVersion = Convert-Version -version $this.Version
|
||||||
|
|
||||||
|
return "${base}/${versionName}/Python-${nativeVersion}.tgz"
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] GetPythonBinary() {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Return name of Python binary.
|
||||||
|
#>
|
||||||
|
|
||||||
|
if ($this.Version.Major -eq 2) { $pythonBinary = "python" } else { $pythonBinary = "python3" }
|
||||||
|
return $pythonBinary
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] Download() {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Download Python sources and extract them at temporary work folder. Returns expanded archive location path.
|
||||||
|
#>
|
||||||
|
|
||||||
|
$sourceUri = $this.GetSourceUri()
|
||||||
|
Write-Host "Sources URI: $sourceUri"
|
||||||
|
|
||||||
|
$archiveFilepath = Download-File -Uri $sourceUri -OutputFolder $this.WorkFolderLocation
|
||||||
|
$expandedSourceLocation = Join-Path -Path $this.TempFolderLocation -ChildPath "SourceCode"
|
||||||
|
New-Item -Path $expandedSourceLocation -ItemType Directory
|
||||||
|
|
||||||
|
Extract-TarArchive -ArchivePath $archiveFilepath -OutputDirectory $expandedSourceLocation
|
||||||
|
Write-Debug "Done; Sources location: $expandedSourceLocation"
|
||||||
|
|
||||||
|
return $expandedSourceLocation
|
||||||
|
}
|
||||||
|
|
||||||
|
[void] CreateInstallationScript() {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create Python artifact installation script based on template specified in InstallationTemplateName property.
|
||||||
|
#>
|
||||||
|
|
||||||
|
$installationScriptLocation = New-Item -Path $this.WorkFolderLocation -Name $this.InstallationScriptName -ItemType File
|
||||||
|
$installationTemplateLocation = Join-Path -Path $this.InstallationTemplatesLocation -ChildPath $this.InstallationTemplateName
|
||||||
|
|
||||||
|
$installationTemplateContent = Get-Content -Path $installationTemplateLocation -Raw
|
||||||
|
|
||||||
|
$variablesToReplace = @{
|
||||||
|
"{{__VERSION_FULL__}}" = $this.Version;
|
||||||
|
"{{__ARCH__}}" = $this.Architecture;
|
||||||
|
}
|
||||||
|
$variablesToReplace.keys | ForEach-Object { $installationTemplateContent = $installationTemplateContent.Replace($_, $variablesToReplace[$_]) }
|
||||||
|
|
||||||
|
$installationTemplateContent | Out-File -FilePath $installationScriptLocation
|
||||||
|
|
||||||
|
Write-Debug "Done; Installation script location: $installationScriptLocation)"
|
||||||
|
}
|
||||||
|
|
||||||
|
[void] Make() {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Executes "make" and "make install" commands for configured build sources. Make output will be writen in build_output.txt located in artifact location folder.
|
||||||
|
#>
|
||||||
|
|
||||||
|
Write-Debug "make Python $($this.Version)-$($this.Architecture) $($this.Platform)"
|
||||||
|
$buildOutputLocation = New-Item -Path $this.WorkFolderLocation -Name "build_output.txt" -ItemType File
|
||||||
|
|
||||||
|
Execute-Command -Command "make 2>&1 | tee $buildOutputLocation" -ErrorAction Continue
|
||||||
|
Execute-Command -Command "make install" -ErrorAction Continue
|
||||||
|
|
||||||
|
Write-Debug "Done; Make log location: $buildOutputLocation"
|
||||||
|
}
|
||||||
|
|
||||||
|
[void] CopyBuildResults() {
|
||||||
|
$buildFolder = $this.GetFullPythonToolcacheLocation()
|
||||||
|
Move-Item -Path "$buildFolder/*" -Destination $this.WorkFolderLocation
|
||||||
|
}
|
||||||
|
|
||||||
|
[void] ArchiveArtifact() {
|
||||||
|
$OutputPath = Join-Path $this.ArtifactFolderLocation $this.OutputArtifactName
|
||||||
|
Create-TarArchive -SourceFolder $this.WorkFolderLocation -ArchivePath $OutputPath
|
||||||
|
}
|
||||||
|
|
||||||
|
[void] Build() {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Build Python artifact from sources.
|
||||||
|
#>
|
||||||
|
|
||||||
|
Write-Host "Prepare Python Hostedtoolcache location..."
|
||||||
|
$this.PreparePythonToolcacheLocation()
|
||||||
|
|
||||||
|
Write-Host "Prepare system environment..."
|
||||||
|
$this.PrepareEnvironment()
|
||||||
|
|
||||||
|
Write-Host "Download Python $($this.Version)[$($this.Architecture)] sources..."
|
||||||
|
$sourcesLocation = $this.Download()
|
||||||
|
|
||||||
|
Push-Location -Path $sourcesLocation
|
||||||
|
Write-Host "Configure for $($this.Platform)..."
|
||||||
|
$this.Configure()
|
||||||
|
|
||||||
|
Write-Host "Make for $($this.Platform)..."
|
||||||
|
$this.Make()
|
||||||
|
Pop-Location
|
||||||
|
|
||||||
|
Write-Host "Generate structure dump"
|
||||||
|
New-ToolStructureDump -ToolPath $this.GetFullPythonToolcacheLocation() -OutputFolder $this.WorkFolderLocation
|
||||||
|
|
||||||
|
Write-Host "Copying build results to destination location"
|
||||||
|
$this.CopyBuildResults()
|
||||||
|
|
||||||
|
Write-Host "Create installation script..."
|
||||||
|
$this.CreateInstallationScript()
|
||||||
|
|
||||||
|
Write-Host "Archive artifact..."
|
||||||
|
$this.ArchiveArtifact()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"version": "3.13.0-beta.2",
|
"version": "3.13.0-beta.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user