mirror of
https://github.com/actions/python-versions.git
synced 2025-12-14 06:26:45 +00:00
Update macos-python-builder.psm1
This commit is contained in:
@@ -1,23 +1,20 @@
|
|||||||
using module "./nix-python-builder.psm1"
|
|
||||||
|
|
||||||
class macOSPythonBuilder : NixPythonBuilder {
|
class macOSPythonBuilder : NixPythonBuilder {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
MacOS Python builder class.
|
MacOS Python builder class.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Contains methods that required to build macOS Python artifact from sources. Inherited from base NixPythonBuilder.
|
Contains methods required to build macOS Python artifacts from sources. Inherited from base NixPythonBuilder.
|
||||||
|
|
||||||
While python.org provides precompiled binaries for macOS, switching to them risks breaking existing customers.
|
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
|
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.
|
so we remain backwards compatible.
|
||||||
|
|
||||||
.PARAMETER platform
|
.PARAMETER platform
|
||||||
The full name of platform for which Python should be built.
|
The full name of the platform for which Python should be built.
|
||||||
|
|
||||||
.PARAMETER version
|
.PARAMETER version
|
||||||
The version of Python that should be built.
|
The version of Python that should be built.
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
macOSPythonBuilder(
|
macOSPythonBuilder(
|
||||||
@@ -31,19 +28,13 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Prepare system environment by installing dependencies and required packages.
|
Prepare system environment by installing dependencies and required packages.
|
||||||
#>
|
#>
|
||||||
if ($this.Version -eq "3.7.17") {
|
|
||||||
# Ensure Homebrew is installed (in case it's not already available)
|
# Only for Python 3.7.17, install additional dependencies
|
||||||
if (-not (Test-Path "/usr/local/bin/brew")) {
|
if ($this.Version -eq "3.7.17") {
|
||||||
Write-Host "Homebrew not found. Installing Homebrew..."
|
Write-Host "Installing additional dependencies for Python 3.7.17..."
|
||||||
Invoke-Expression -Command "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
|
# Install necessary dependencies for Python 3.7.17
|
||||||
# Once Homebrew is installed, install the dependencies
|
Execute-Command -Command "brew install bzip2 zlib readline ncurses sqlite3 openssl@1.1"
|
||||||
Write-Host "Installing dependencies: bzip2, readline, ncurses..."
|
}
|
||||||
Execute-Command -Command "brew install bzip2 readline ncurses"
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Write-Host "Homebrew is already installed."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Configure() {
|
[void] Configure() {
|
||||||
@@ -76,10 +67,10 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
$env:LDFLAGS = "-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
|
$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:CFLAGS = "-I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
|
||||||
} else {
|
} else {
|
||||||
$configureString += " --with-openssl=/usr/local/opt/openssl@3"
|
$configureString += " --with-openssl=/usr/local/opt/openssl@1.1" # For Python 3.7.x, use OpenSSL 1.1
|
||||||
|
|
||||||
# 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
|
# For Python 3.7.2, 3.7.3, and 3.7.17 we need to provide PATH for zlib to pack it properly.
|
||||||
# with the error: zipimport.ZipImportError: can't decompress data; zlib not available
|
# 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") {
|
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:LDFLAGS = "-L/usr/local/opt/zlib/lib"
|
||||||
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
|
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
|
||||||
@@ -87,9 +78,11 @@ class macOSPythonBuilder : NixPythonBuilder {
|
|||||||
|
|
||||||
if ($this.Version -gt "3.7.12") {
|
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'"
|
$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") {
|
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: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"
|
$env:CFLAGS += " -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix ncurses)/include"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user