feat: build macOS arm64 packages

This commit is contained in:
mayeut 2022-12-11 16:35:04 +01:00
parent 256e6ddd57
commit fb2e761b1b
No known key found for this signature in database
GPG Key ID: 8B03CED67D3ABFBA
5 changed files with 24 additions and 18 deletions

View File

@ -15,7 +15,7 @@ on:
PLATFORMS:
description: 'Platforms for execution in "os" or "os_arch" format (arch is "x64" by default)'
required: true
default: 'ubuntu-20.04,ubuntu-22.04,macos-11,windows-2019_x64,windows-2019_x86'
default: 'ubuntu-20.04,ubuntu-22.04,macos-11_x64,macos-11_arm64,windows-2019_x64,windows-2019_x86'
pull_request:
paths-ignore:
- 'versions-manifest.json'
@ -39,7 +39,7 @@ jobs:
- name: Generate execution matrix
id: generate-matrix
run: |
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-20.04,ubuntu-22.04,macos-11,windows-2019_x64,windows-2019_x86' }}".Split(",").Trim()
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-20.04,ubuntu-22.04,macos-11,macos-11_arm64,windows-2019_x64,windows-2019_x86' }}".Split(",").Trim()
$matrix = @()
foreach ($configuration in $configurations) {
@ -155,6 +155,7 @@ jobs:
$pesterContainer = New-PesterContainer -Path './python-tests.ps1' -Data @{
Version="${{ env.VERSION }}";
Platform="${{ matrix.platform }}";
Architecture="${{ matrix.arch }}";
}
$Result = Invoke-Pester -Container $pesterContainer -PassThru
if ($Result.FailedCount -gt 0) {

View File

@ -151,6 +151,7 @@ class macOSPythonBuilder : NixPythonBuilder {
$variablesToReplace = @{
"{{__VERSION_FULL__}}" = $this.Version;
"{{__PKG_NAME__}}" = $this.GetPkgName();
"{{__ARCH__}}" = $this.Architecture;
}
$variablesToReplace.keys | ForEach-Object { $installationTemplateContent = $installationTemplateContent.Replace($_, $variablesToReplace[$_]) }
@ -166,7 +167,7 @@ class macOSPythonBuilder : NixPythonBuilder {
$PkgVersion = [semver]"3.11.0-beta.1"
if ($this.Version -ge $PkgVersion) {
if (($this.Version -ge $PkgVersion) -or ($this.Architecture -eq "arm64")) {
Write-Host "Download Python $($this.Version) [$($this.Architecture)] package..."
$this.DownloadPkg()

View File

@ -2,6 +2,7 @@ set -e
PYTHON_FULL_VERSION="{{__VERSION_FULL__}}"
PYTHON_PKG_NAME="{{__PKG_NAME__}}"
ARCH="{{__ARCH__}}"
MAJOR_VERSION=$(echo $PYTHON_FULL_VERSION | cut -d '.' -f 1)
MINOR_VERSION=$(echo $PYTHON_FULL_VERSION | cut -d '.' -f 2)
@ -18,7 +19,7 @@ fi
PYTHON_TOOLCACHE_PATH=$TOOLCACHE_ROOT/Python
PYTHON_TOOLCACHE_VERSION_PATH=$PYTHON_TOOLCACHE_PATH/$PYTHON_FULL_VERSION
PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/x64
PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/$ARCH
PYTHON_FRAMEWORK_PATH="/Library/Frameworks/Python.framework/Versions/${MAJOR_VERSION}.${MINOR_VERSION}"
PYTHON_APPLICATION_PATH="/Applications/Python ${MAJOR_VERSION}.${MINOR_VERSION}"
@ -29,10 +30,10 @@ if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
else
# remove ALL other directories for same major.minor python versions
find $PYTHON_TOOLCACHE_PATH -name "${MAJOR_VERSION}.${MINOR_VERSION}.*"|while read python_version;do
python_version_x64="$python_version/x64"
if [ -e "$python_version_x64" ];then
echo "Deleting Python $python_version_x64"
rm -rf "$python_version_x64"
python_version_arch="$python_version/$ARCH"
if [ -e "$python_version_arch" ];then
echo "Deleting Python $python_version_arch"
rm -rf "$python_version_arch"
fi
done
fi
@ -75,4 +76,4 @@ echo "Install OpenSSL certificates"
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
echo "Create complete file"
touch $PYTHON_TOOLCACHE_VERSION_PATH/x64.complete
touch $PYTHON_TOOLCACHE_VERSION_PATH/${ARCH}.complete

View File

@ -2,7 +2,9 @@ param (
[semver] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()]
$Version,
[string] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()]
$Platform
$Platform,
[string] [Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()]
$Architecture
)
Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
@ -56,7 +58,7 @@ Describe "Tests" {
# }
# }
if (($Version -ge "3.2.0") -and ($Version -lt "3.11.0")) {
if (($Version -ge "3.2.0") -and ($Version -lt "3.11.0") -and (($Platform -ne "darwin") -or ($Architecture -ne "arm64"))) {
It "Check if sqlite3 module is installed" {
"python ./sources/python-sqlite3.py" | Should -ReturnZeroExitCode
}
@ -80,7 +82,7 @@ Describe "Tests" {
It "Check if python configuration is correct" {
$nativeVersion = Convert-Version -version $Version
"python ./sources/python-config-test.py $Version $nativeVersion" | Should -ReturnZeroExitCode
"python ./sources/python-config-test.py $Version $nativeVersion $Architecture" | Should -ReturnZeroExitCode
}
It "Check if shared libraries are linked correctly" {

View File

@ -9,12 +9,13 @@ import os
os_type = platform.system()
version = sys.argv[1]
nativeVersion = sys.argv[2]
architecture = sys.argv[3]
versions=version.split(".")
version_major=int(versions[0])
version_minor=int(versions[1])
pkg_installer = os_type == 'Darwin' and (version_major == 3 and version_minor >= 11)
pkg_installer = os_type == 'Darwin' and ((version_major == 3 and version_minor >= 11) or (architecture == "arm64"))
lib_dir_path = sysconfig.get_config_var('LIBDIR')
ld_library_name = sysconfig.get_config_var('LDLIBRARY')