Compare commits

..

33 Commits

Author SHA1 Message Date
aparnajyothi-y
9ad4c1fcaa Update build-python-packages.yml 2024-06-14 10:31:10 +05:30
aparnajyothi-y
3f1c6125df Update build-python-packages.yml 2024-06-14 10:19:44 +05:30
aparnajyothi-y
b1d12fe818 Update build-python-packages.yml 2024-06-14 10:14:34 +05:30
aparnajyothi-y
d464ee3cc6 Update build-python-packages.yml 2024-06-14 10:12:44 +05:30
aparnajyothi-y
61e93b288d Update build-python-packages.yml 2024-06-14 10:11:48 +05:30
aparnajyothi-y
8d965711ba Update build-python-packages.yml 2024-06-14 10:05:34 +05:30
aparnajyothi-y
b228cba84e Update build-python-packages.yml 2024-06-14 09:52:27 +05:30
aparnajyothi-y
fd9b186705 Update build-python-packages.yml 2024-05-29 17:40:28 +05:30
aparnajyothi-y
a15689f2ac Update build-python-packages.yml 2024-05-29 17:18:57 +05:30
aparnajyothi-y
be0e5a895c Update build-python-packages.yml 2024-05-29 17:12:40 +05:30
aparnajyothi-y
04c0db46b5 Update build-python-packages.yml 2024-05-29 17:07:23 +05:30
aparnajyothi-y
cb822fbaf1 Update build-python-packages.yml 2024-05-29 17:04:16 +05:30
aparnajyothi-y
1d262fc400 Update build-python-packages.yml 2024-05-29 17:00:46 +05:30
aparnajyothi-y
06ec0e912f Update build-python-packages.yml 2024-05-29 16:54:45 +05:30
aparnajyothi-y
30c053652b Update build-python-packages.yml 2024-05-29 16:43:41 +05:30
aparnajyothi-y
411060a14d Update build-python-packages.yml 2024-05-29 16:41:10 +05:30
aparnajyothi-y
45c77b2a3a Update build-python-packages.yml 2024-05-29 16:39:08 +05:30
aparnajyothi-y
3af71f81fb Update build-python-packages.yml 2024-05-29 16:36:07 +05:30
aparnajyothi-y
2031f98157 Update build-python-packages.yml 2024-05-29 16:32:36 +05:30
aparnajyothi-y
ac6f4c6a01 Update build-python-packages.yml 2024-05-29 16:27:56 +05:30
aparnajyothi-y
a185c39c53 Update build-python-packages.yml 2024-05-29 16:22:49 +05:30
aparnajyothi-y
9c2e25fa64 Update build-python-packages.yml 2024-05-29 16:11:31 +05:30
aparnajyothi-y
c87f998dfb Update build-python-packages.yml 2024-05-29 16:09:05 +05:30
aparnajyothi-y
a18ca9186b Update build-python-packages.yml 2024-05-29 15:54:06 +05:30
aparnajyothi-y
12f1ddaf19 Update build-python-packages.yml 2024-05-29 15:47:10 +05:30
aparnajyothi-y
22bd58f5ab Update build-python-packages.yml 2024-05-29 15:30:12 +05:30
aparnajyothi-y
91d36e5783 Update build-python-packages.yml 2024-05-29 15:28:53 +05:30
aparnajyothi-y
567e9060f4 Update build-python-packages.yml 2024-05-29 15:19:31 +05:30
aparnajyothi-y
10da5bd845 Update build-python-packages.yml 2024-05-29 15:15:29 +05:30
aparnajyothi-y
b6f9ad0531 Update build-python-packages.yml 2024-05-29 15:13:15 +05:30
aparnajyothi-y
0d0f3060e3 Update build-python-packages.yml 2024-05-29 15:03:12 +05:30
aparnajyothi-y
948f51aaf0 Update build-python-packages.yml 2024-05-29 14:58:10 +05:30
aparnajyothi-y
43b4fed22f Update build-python-packages.yml 2024-05-29 14:52:21 +05:30
10 changed files with 432 additions and 2440 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,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,macos-13_x64,macos-14_arm64,windows-2019_x64,windows-2019_x86,windows-2019_arm64'
default: 'setup-actions-windows-arm64-4-core'
pull_request:
paths-ignore:
- 'versions-manifest.json'
@@ -28,20 +28,36 @@ env:
VERSION: ${{ inputs.VERSION || '3.12.3' }}
defaults:
run:
shell: pwsh
shell: 'C:\Program Files\PowerShell\7\pwsh.exe -Command {0}'
jobs:
generate_matrix:
install_Pwsh_git:
runs-on: setup-actions-windows-arm64-4-core
steps:
- run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install -y pwsh
choco install -y git --version=2.18.0
'C:\Program Files\PowerShell\7\' | Out-File $env:GITHUB_PATH -Append
'C:\Program Files\Git\bin' | Out-File $env:GITHUB_PATH -Append
shell: powershell
generate_matrix:
needs: [install_Pwsh_git]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Generate execution matrix
id: generate-matrix
run: |
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-20.04,ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,macos-13,macos-14_arm64,windows-2019_x64,windows-2019_x86,windows-2019_arm64' }}".Split(",").Trim()
- name: Generate execution matrix
id: generate-matrix
run: |
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-20.04,ubuntu-22.04,ubuntu-24.04,macos-11,macos-11_arm64,windows-2019_x64,windows-2019_x86' }}".Split(",").Trim()
$matrix = @()
foreach ($configuration in $configurations) {
$parts = $configuration.Split("_")
$os = $parts[0]
@@ -51,17 +67,6 @@ jobs:
"*macos*" { $platform = 'darwin' }
"*windows*" { $platform = 'win32' }
}
if ($configuration -eq "ubuntu-22.04_arm64") {
$os = "setup-actions-ubuntu-arm64-2-core"
}
elseif ($configuration -eq "ubuntu-24.04_arm64") {
$os = "setup-actions-ubuntu24-arm64-2-core"
}
elseif ($configuration -eq "windows-2019_arm64") {
$os = "setup-actions-windows-arm64-4-core"
}
$matrix += @{
'platform' = $platform
'os' = $os
@@ -69,9 +74,10 @@ jobs:
}
}
echo "matrix=$($matrix | ConvertTo-Json -Compress -AsArray)" >> $env:GITHUB_OUTPUT
build_python:
needs: generate_matrix
build_python:
needs: [install_Pwsh_git, generate_matrix]
strategy:
fail-fast: false
matrix:
@@ -80,40 +86,16 @@ jobs:
env:
ARTIFACT_NAME: python-${{ inputs.VERSION || '3.12.3' }}-${{ matrix.platform }}-${{ matrix.arch }}
steps:
- name: Setup Environment on Windows ARM64 Runner
if: matrix.os == 'setup-actions-windows-arm64-4-core'
shell: powershell
run: |
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
echo "C:\ProgramData\Chocolatey\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# Install PowerShell
choco install powershell-core -y
echo "C:\Program Files\PowerShell\7" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# Install Git
choco install git -y
echo "C:\Program Files\Git\cmd" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# Install 7-Zip
choco install 7zip -y
echo "C:\ProgramData\chocolatey\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: true
submodules: false
- name: Build Python ${{ env.VERSION }}
run: |
./builders/build-python.ps1 -Version $env:VERSION `
-Platform ${{ matrix.platform }} -Architecture ${{ matrix.arch }}
- name: Publish artifact
uses: actions/upload-artifact@v4
with:
@@ -121,8 +103,8 @@ jobs:
path: ${{ runner.temp }}/artifact
if-no-files-found: error
test_python:
needs: [generate_matrix, build_python]
test_python:
needs: [install_Pwsh_git, generate_matrix, build_python]
strategy:
fail-fast: false
matrix:
@@ -131,33 +113,11 @@ jobs:
env:
ARTIFACT_NAME: python-${{ inputs.VERSION || '3.12.3' }}-${{ matrix.platform }}-${{ matrix.arch }}
steps:
- name: Setup Environment on Windows ARM64 Runner
if: matrix.os == 'setup-actions-windows-arm64-4-core'
shell: powershell
run: |
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
echo "C:\ProgramData\Chocolatey\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# Install PowerShell
choco install powershell-core -y
echo "C:\Program Files\PowerShell\7" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# Install Git
choco install git -y
echo "C:\Program Files\Git\cmd" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# Install 7-Zip
choco install 7zip -y
echo "C:\ProgramData\chocolatey\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: true
submodules: false
- name: Fully cleanup the toolcache directory before testing
run: ./helpers/clean-toolcache.ps1 -ToolName "Python"
@@ -214,7 +174,7 @@ jobs:
- name: Run tests
run: |
Install-Module Pester -Force -Scope CurrentUser -SkipPublisherCheck
Install-Module Pester -Force -Scope CurrentUser
Import-Module Pester
$pesterContainer = New-PesterContainer -Path './python-tests.ps1' -Data @{
Version="${{ env.VERSION }}";
@@ -228,13 +188,14 @@ jobs:
}
working-directory: ${{ github.workspace }}/tests
publish_release:
publish_release:
name: Publish release
if: github.event_name == 'workflow_dispatch' && inputs.PUBLISH_RELEASES
needs: test_python
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Publish Release ${{ env.VERSION }}
id: create_release
@@ -278,7 +239,7 @@ jobs:
});
}
trigger_pr:
trigger_pr:
name: Trigger "Create Pull Request" workflow
needs: publish_release
runs-on: ubuntu-latest
@@ -294,3 +255,4 @@ jobs:
workflow_id: 'create-pr.yml',
ref: 'main'
});

View File

@@ -13,5 +13,4 @@ jobs:
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
with:
languages: '["python"]'
languages: "['python']"

View File

@@ -14,8 +14,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13]
python: [3.9.13, 3.10.11, 3.11.8, 3.12.7, 3.13.0]
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04]
python: [3.9.13, 3.10.11, 3.11.8]
steps:
- name: setup-python ${{ matrix.python }}
uses: actions/setup-python@v5

View File

@@ -6,17 +6,18 @@ class macOSPythonBuilder : NixPythonBuilder {
MacOS Python builder class.
.DESCRIPTION
Contains methods required to build macOS Python artifacts from sources. Inherited from base NixPythonBuilder.
Contains methods that required to build macOS Python artifact from sources. Inherited from base NixPythonBuilder.
While python.org provides precompiled binaries for macOS, switching to them risks breaking existing customers.
If we wanted to start using the official binaries instead of building from source, we should avoid changing previous versions
so we remain backwards compatible.
.PARAMETER platform
The full name of the platform for which Python should be built.
The full name of platform for which Python should be built.
.PARAMETER version
The version of Python that should be built.
#>
macOSPythonBuilder(
@@ -30,18 +31,14 @@ class macOSPythonBuilder : NixPythonBuilder {
.SYNOPSIS
Prepare system environment by installing dependencies and required packages.
#>
# Only for Python 3.7.17, install additional dependencies
if ($this.Version -eq "3.7.17") {
Write-Host "Installing additional dependencies for Python 3.7.17..."
# Install necessary dependencies for Python 3.7.17
Execute-Command -Command "brew install bzip2 zlib readline ncurses sqlite3 openssl@3"
# Ensure the environment variables for zlib are set correctly
$zlibPrefix = (brew --prefix zlib)
$env:LDFLAGS += " -L$($zlibPrefix)/lib"
$env:CFLAGS += " -I$($zlibPrefix)/include"
}
if ($this.Version -eq "3.7.17") {
# We have preinstalled ncurses and readLine on the hoster runners. But we need to install bzip2 for
# setting up an environemnt
# If we get any issues realted to ncurses or readline we can try to run this command
# brew install ncurses readline
Execute-Command -Command "brew install bzip2"
}
}
[void] Configure() {
@@ -71,13 +68,13 @@ class macOSPythonBuilder : NixPythonBuilder {
### and then add the appropriate paths for the header and library files to configure command.
### Link to documentation (https://cpython-devguide.readthedocs.io/setup/#build-dependencies)
if ($this.Version -lt "3.7.0") {
$env:LDFLAGS = "-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
$env:CFLAGS = "-I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
$env:LDFLAGS = "-L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/zlib/lib"
$env:CFLAGS = "-I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/zlib/include"
} else {
$configureString += " --with-openssl=/usr/local/opt/openssl@1.1" # For Python 3.7.x, use OpenSSL 1.1
$configureString += " --with-openssl=/usr/local/opt/openssl@1.1"
# For Python 3.7.2, 3.7.3, and 3.7.17 we need to provide PATH for zlib to pack it properly.
# Otherwise, the build will fail with the error: zipimport.ZipImportError: can't decompress data; zlib not available
# For Python 3.7.2 and 3.7.3 we need to provide PATH for zlib to pack it properly. Otherwise the build will fail
# with the error: zipimport.ZipImportError: can't decompress data; zlib not available
if ($this.Version -eq "3.7.2" -or $this.Version -eq "3.7.3" -or $this.Version -eq "3.7.17") {
$env:LDFLAGS = "-L/usr/local/opt/zlib/lib"
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
@@ -85,11 +82,9 @@ class macOSPythonBuilder : NixPythonBuilder {
if ($this.Version -gt "3.7.12") {
$configureString += " --with-tcltk-includes='-I /usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
}
}
# Specific for Python 3.7.17
if ($this.Version -eq "3.7.17") {
Write-Host "Setting environment for Python 3.7.17..."
$env:LDFLAGS += " -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix ncurses)/lib"
$env:CFLAGS += " -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix ncurses)/include"
}

View File

@@ -97,7 +97,6 @@ class NixPythonBuilder : PythonBuilder {
$variablesToReplace = @{
"{{__VERSION_FULL__}}" = $this.Version;
"{{__ARCH__}}" = $this.Architecture;
}
$variablesToReplace.keys | ForEach-Object { $installationTemplateContent = $installationTemplateContent.Replace($_, $variablesToReplace[$_]) }

View File

@@ -60,8 +60,6 @@ class WinPythonBuilder : PythonBuilder {
} else {
$ArchitectureExtension = ".amd64"
}
}elseif ($this.Architecture -eq "arm64") {
$ArchitectureExtension = "-arm64"
}
return $ArchitectureExtension

View File

@@ -23,47 +23,25 @@ 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}"
# Check if zlib is installed
echo "Checking if zlib is installed..."
if ! brew list zlib &>/dev/null; then
echo "Installing zlib via brew..."
brew install zlib
else
echo "zlib already installed."
fi
# Only for Python 3.7.17, install additional dependencies like zlib and others
if [ "$MAJOR_VERSION" -eq 3 ] && [ "$MINOR_VERSION" -eq 7 ] && [ "$PYTHON_FULL_VERSION" == "3.7.17" ]; then
echo "Installing additional dependencies for Python 3.7.17..."
brew install bzip2 readline ncurses sqlite3 openssl@3
# Ensure the environment variables for zlib are set correctly
ZLIB_PREFIX=$(brew --prefix zlib)
export LDFLAGS="-L${ZLIB_PREFIX}/lib"
export CFLAGS="-I${ZLIB_PREFIX}/include"
export CPPFLAGS="-I${ZLIB_PREFIX}/include"
echo "zlib linked at ${ZLIB_PREFIX}/lib"
fi
# Check if Python hostedtoolcache folder exists...
echo "Check if Python hostedtoolcache folder exists..."
echo "Check if Python hostedtoolcache folder exist..."
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
echo "Creating Python hostedtoolcache folder..."
mkdir -p $PYTHON_TOOLCACHE_PATH
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
# 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_arch="$python_version/$ARCH"
if [ -e "$python_version_arch" ]; then
if [ -e "$python_version_arch" ];then
echo "Deleting Python $python_version_arch"
rm -rf "$python_version_arch"
fi
done
fi
echo "Installing Python binaries from prebuilt package"
echo "Install Python binaries from prebuilt package"
sudo installer -pkg $PYTHON_PKG_NAME -target /
echo "Creating hostedtoolcache symlinks (Required for the backward compatibility)"
echo "Create hostedtoolcach symlinks (Required for the backward compatibility)"
echo "Create Python $PYTHON_FULL_VERSION folder"
mkdir -p $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
cd $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
@@ -73,7 +51,7 @@ ln -s "${PYTHON_FRAMEWORK_PATH}/include" include
ln -s "${PYTHON_FRAMEWORK_PATH}/share" share
ln -s "${PYTHON_FRAMEWORK_PATH}/lib" lib
echo "Creating additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)"
echo "Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)"
ln -s ./bin/$PYTHON_MAJOR_DOT_MINOR python
cd bin/
@@ -95,8 +73,8 @@ export PIP_ROOT_USER_ACTION=ignore
./python -m ensurepip
./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location
echo "Installing OpenSSL certificates"
echo "Install OpenSSL certificates"
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
echo "Creating complete file"
echo "Create complete file"
touch $PYTHON_TOOLCACHE_VERSION_PATH/${ARCH}.complete

View File

@@ -1,7 +1,6 @@
set -e
PYTHON_FULL_VERSION="{{__VERSION_FULL__}}"
ARCH="{{__ARCH__}}"
MAJOR_VERSION=$(echo $PYTHON_FULL_VERSION | cut -d '.' -f 1)
MINOR_VERSION=$(echo $PYTHON_FULL_VERSION | cut -d '.' -f 2)
@@ -18,7 +17,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/$ARCH
PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/x64
echo "Check if Python hostedtoolcache folder exist..."
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
@@ -55,4 +54,4 @@ export PIP_ROOT_USER_ACTION=ignore
./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location
echo "Create complete file"
touch $PYTHON_TOOLCACHE_VERSION_PATH/$ARCH.complete
touch $PYTHON_TOOLCACHE_VERSION_PATH/x64.complete

View File

@@ -28,7 +28,7 @@ if os_type == 'Darwin': expected_ld_library_extension = 'dylib'
if pkg_installer:
expected_lib_dir_path = f'/Library/Frameworks/Python.framework/Versions/{version_major}.{version_minor}/lib'
else:
expected_lib_dir_path = f'{os.getenv("AGENT_TOOLSDIRECTORY")}/Python/{version}/{architecture}/lib'
expected_lib_dir_path = f'{os.getenv("AGENT_TOOLSDIRECTORY")}/Python/{version}/x64/lib'
# Check modules
### Validate libraries path
@@ -54,15 +54,15 @@ else:
if os_type == 'Darwin':
### Validate openssl links
if version_major == 3 and version_minor < 7:
expected_ldflags = '-L/usr/local/opt/openssl@3/lib'
expected_ldflags = '-L/usr/local/opt/openssl@1.1/lib'
ldflags = sysconfig.get_config_var('LDFLAGS')
if not expected_ldflags in ldflags:
print('Invalid ldflags: %s; Expected: %s' % (ldflags, expected_ldflags))
exit(1)
else:
expected_openssl_includes = '-I/usr/local/opt/openssl@3/include'
expected_openssl_ldflags ='-L/usr/local/opt/openssl@3/lib'
expected_openssl_includes = '-I/usr/local/opt/openssl@1.1/include'
expected_openssl_ldflags ='-L/usr/local/opt/openssl@1.1/lib'
openssl_includes = sysconfig.get_config_var('OPENSSL_INCLUDES')
openssl_ldflags = sysconfig.get_config_var('OPENSSL_LDFLAGS')

File diff suppressed because it is too large Load Diff