Skip to content
Merged
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
21 changes: 19 additions & 2 deletions .github/workflows/build-python-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
PLATFORMS:
description: 'Platforms for execution in "os" or "os_arch" format (arch is "x64" by default)'
required: true
default: 'ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,macos-15-intel_x64,macos-14_arm64,windows-2022_x64,windows-2022_x86,windows-11_arm64'
default: 'ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,rhel-9,rhel-10,macos-15-intel_x64,macos-14_arm64,windows-2022_x64,windows-2022_x86,windows-11_arm64'
pull_request:
paths-ignore:
- 'versions-manifest.json'
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Generate execution matrix
id: generate-matrix
run: |
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,macos-15-intel,macos-14_arm64,windows-2022_x64,windows-2022_x86,windows-11_arm64' }}".Split(",").Trim()
[String[]]$configurations = "${{ inputs.platforms || 'ubuntu-22.04,ubuntu-22.04_arm64,ubuntu-24.04,ubuntu-24.04_arm64,rhel-9,rhel-10,macos-15-intel,macos-14_arm64,windows-2022_x64,windows-2022_x86,windows-11_arm64' }}".Split(",").Trim()
[String[]]$buildModes = "${{ inputs.threading_build_modes || 'default' }}".Split(",").Trim()
$matrix = @()

Expand All @@ -55,6 +55,7 @@ jobs:
$arch = if ($parts[1]) {$parts[1]} else {"x64"}
switch -wildcard ($os) {
"*ubuntu*" { $platform = $os.Replace("ubuntu","linux"); if ($arch -eq "arm64" ) { $os = "${os}-arm" } }
"*rhel*" { $platform = $os; $os = $os.Replace("rhel","setup-actions-rhel") }
"*macos*" { $platform = 'darwin' }
"*windows*" { $platform = 'win32'; if ($arch -eq "arm64" ) { $os = "${os}-arm" } }
}
Expand Down Expand Up @@ -85,6 +86,14 @@ jobs:
env:
ARTIFACT_NAME: python-${{ inputs.VERSION || '3.13.7' }}-${{ matrix.platform }}-${{ matrix.arch }}
steps:
- name: Install prerequisites
if: startsWith(matrix.platform, 'rhel')
shell: bash
run: |
RHEL_VERSION=$(rpm -E %rhel)
sudo dnf install -y "https://packages.microsoft.com/config/rhel/${RHEL_VERSION}/packages-microsoft-prod.rpm"
sudo dnf install -y powershell git

- name: Check out repository code
uses: actions/checkout@v6
with:
Expand Down Expand Up @@ -112,6 +121,14 @@ jobs:
env:
ARTIFACT_NAME: python-${{ inputs.VERSION || '3.13.7' }}-${{ matrix.platform }}-${{ matrix.arch }}
steps:
- name: Install prerequisites
if: startsWith(matrix.platform, 'rhel')
shell: bash
run: |
RHEL_VERSION=$(rpm -E %rhel)
sudo dnf install -y "https://packages.microsoft.com/config/rhel/${RHEL_VERSION}/packages-microsoft-prod.rpm"
sudo dnf install -y powershell git tk sqlite-libs gcc

- name: Check out repository code
uses: actions/checkout@v6
with:
Expand Down
3 changes: 3 additions & 0 deletions builders/build-python.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using module "./win-python-builder.psm1"
using module "./ubuntu-python-builder.psm1"
using module "./rhel-python-builder.psm1"
using module "./macos-python-builder.psm1"

<#
Expand Down Expand Up @@ -58,6 +59,8 @@ function Get-PythonBuilder {

if ($Platform -match 'win32') {
$builder = [WinPythonBuilder]::New($Version, $Architecture, $Platform)
} elseif ($Platform -match 'rhel') {
$builder = [RhelPythonBuilder]::New($Version, $Architecture, $Platform)
} elseif ($Platform -match 'linux') {
$builder = [UbuntuPythonBuilder]::New($Version, $Architecture, $Platform)
} elseif ($Platform -match 'darwin') {
Expand Down
88 changes: 88 additions & 0 deletions builders/rhel-python-builder.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using module "./nix-python-builder.psm1"

class RhelPythonBuilder : NixPythonBuilder {
<#
.SYNOPSIS
RHEL Python builder class.

.DESCRIPTION
Contains methods that required to build RHEL Python artifact from sources. Inherited from base NixPythonBuilder.

.PARAMETER platform
The full name of platform for which Python should be built.

.PARAMETER version
The version of Python that should be built.

#>

RhelPythonBuilder(
[semver] $version,
[string] $architecture,
[string] $platform
) : Base($version, $architecture, $platform) { }

[void] Configure() {
<#
.SYNOPSIS
Execute configure script with required parameters.
#>

$pythonBinariesLocation = $this.GetFullPythonToolcacheLocation()

### To build Python with SO we must pass full path to lib folder to the linker
$env:LDFLAGS="-Wl,--rpath=${pythonBinariesLocation}/lib"
$configureString = "./configure"
$configureString += " --prefix=$pythonBinariesLocation"
$configureString += " --enable-shared"
$configureString += " --enable-optimizations"

if ($this.IsFreeThreaded()) {
if ($this.Version -lt "3.13.0") {
Write-Host "Python versions lower than 3.13.0 do not support free threading"
exit 1
}
$configureString += " --disable-gil"
}

### Compile with support of loadable sqlite extensions.
### Link to documentation (https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.enable_load_extension)
$configureString += " --enable-loadable-sqlite-extensions"

Write-Host "The passed configure options are: "
Write-Host $configureString

Execute-Command -Command $configureString
}

[void] PrepareEnvironment() {
<#
.SYNOPSIS
Prepare system environment by installing dependencies and required packages.
#>

if ($this.Version -lt "3.9.0") {
Write-Host "Python versions lower than 3.9.0 are not supported"
exit 1
}

### Install dependent packages
@(
"make",
"gcc",
"gcc-c++",
"openssl-devel",
"zlib-devel",
"bzip2-devel",
"sqlite-devel",
"ncurses-devel",
"readline-devel",
"gdbm-devel",
"xz-devel",
"libffi-devel",
"tk-devel"
) | ForEach-Object {
Execute-Command -Command "sudo dnf install -y $_"
}
}
}
4 changes: 2 additions & 2 deletions config/python-manifest-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"regex": "python-\\d+\\.\\d+\\.\\d+-(\\w+\\.\\d+)?-?(\\w+)-(\\d+\\.\\d+)?-?((x|arm)\\d+(-freethreaded)?)",
"regex": "python-\\d+\\.\\d+\\.\\d+-(\\w+\\.\\d+)?-?(\\w+)-(\\d+(\\.\\d+)?)?-?((x|arm)\\d+(-freethreaded)?)",
"groups": {
"arch": 4,
"arch": 5,
"platform": 2,
"platform_version": 3
}
Expand Down
12 changes: 10 additions & 2 deletions tests/ManifestConfig.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ $stableTestCases = @(
@{ ReleaseName = "python-3.13.0-linux-20.04-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "linux"; platform_version = "20.04"; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.13.0-linux-22.04-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "linux"; platform_version = "22.04"; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.13.0-win32-x64-freethreaded.zip"; ExpectedResult = @{ platform = "win32"; platform_version = $null; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.13.0-win32-x86-freethreaded.zip"; ExpectedResult = @{ platform = "win32"; platform_version = $null; arch = "x86-freethreaded"} }
@{ ReleaseName = "python-3.13.0-win32-x86-freethreaded.zip"; ExpectedResult = @{ platform = "win32"; platform_version = $null; arch = "x86-freethreaded"} },
@{ ReleaseName = "python-3.13.0-rhel-9-x64.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "9"; arch = "x64"} },
@{ ReleaseName = "python-3.13.0-rhel-10-x64.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "10"; arch = "x64"} },
@{ ReleaseName = "python-3.13.0-rhel-9-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "9"; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.13.0-rhel-10-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "10"; arch = "x64-freethreaded"} }

) | ForEach-Object { $_.Configuration = $Configuration; $_ }

Expand All @@ -29,7 +33,11 @@ $unstableTestCases = @(
@{ ReleaseName = "python-3.14.0-alpha.5-linux-20.04-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "linux"; platform_version = "20.04"; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.14.0-alpha.5-linux-22.04-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "linux"; platform_version = "22.04"; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.14.0-alpha.5-win32-x64-freethreaded.zip"; ExpectedResult = @{ platform = "win32"; platform_version = $null; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.14.0-alpha.5-win32-x86-freethreaded.zip"; ExpectedResult = @{ platform = "win32"; platform_version = $null; arch = "x86-freethreaded"} }
@{ ReleaseName = "python-3.14.0-alpha.5-win32-x86-freethreaded.zip"; ExpectedResult = @{ platform = "win32"; platform_version = $null; arch = "x86-freethreaded"} },
@{ ReleaseName = "python-3.14.0-alpha.5-rhel-9-x64.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "9"; arch = "x64"} },
@{ ReleaseName = "python-3.14.0-alpha.5-rhel-10-x64.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "10"; arch = "x64"} },
@{ ReleaseName = "python-3.14.0-alpha.5-rhel-9-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "9"; arch = "x64-freethreaded"} },
@{ ReleaseName = "python-3.14.0-alpha.5-rhel-10-x64-freethreaded.tar.gz"; ExpectedResult = @{ platform = "rhel"; platform_version = "10"; arch = "x64-freethreaded"} }

) | ForEach-Object { $_.Configuration = $Configuration; $_ }

Expand Down
2 changes: 1 addition & 1 deletion tests/python-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Describe "Tests" {
"pip uninstall requests -y" | Should -ReturnZeroExitCode
}

if (IsNixPlatform $Platform) {
if ((IsNixPlatform $Platform) -or ($Platform -match "rhel")) {

It "Check for failed modules in build_output" {
$buildOutputLocation = Join-Path $env:RUNNER_TEMP "build_output.txt"
Expand Down
3 changes: 2 additions & 1 deletion tests/sources/python-config-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
if pkg_installer:
expected_lib_dir_path = f'/Library/Frameworks/{framework_name}/Versions/{version_major}.{version_minor}/lib'
else:
expected_lib_dir_path = f'{os.getenv("AGENT_TOOLSDIRECTORY")}/Python/{version}/{architecture}/lib'
tools_dir = os.getenv("AGENT_TOOLSDIRECTORY") or os.getenv("RUNNER_TOOL_CACHE")
expected_lib_dir_path = f'{tools_dir}/Python/{version}/{architecture}/lib'

# Check modules
### Validate libraries path
Expand Down
Loading