10000 Update macos-python-builder.psm1 · actions/python-versions@d43da0c · GitHub
[go: up one dir, main page]

Skip to content

Commit d43da0c

Browse files
Update macos-python-builder.psm1
1 parent c0cdd73 commit d43da0c

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

builders/macos-python-builder.psm1

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
using module "./nix-python-builder.psm1"
2-
31
class macOSPythonBuilder : NixPythonBuilder {
42
<#
53
.SYNOPSIS
64
MacOS Python builder class.
75
86
.DESCRIPTION
9-
Contains methods that required to build macOS Python artifact from sources. Inherited from base NixPythonBuilder.
7+
Contains methods required to build macOS Python artifacts from sources. Inherited from base NixPythonBuilder.
108
119
While python.org provides precompiled binaries for macOS, switching to them risks breaking existing customers.
1210
If we wanted to start using the official binaries instead of building from source, we should avoid changing previous versions
1311
so we remain backwards compatible.
1412
1513
.PARAMETER platform
16-
The full name of platform for which Python should be built.
14+
The full name of the platform for which Python should be built.
1715
1816
.PARAMETER version
1917
The version of Python that should be built.
20-
2118
#>
2219

2320
macOSPythonBuilder(
@@ -31,19 +28,13 @@ class macOSPythonBuilder : NixPythonBuilder {
3128
.SYNOPSIS
3229
Prepare system environment by installing dependencies and required packages.
3330
#>
34-
if ($this.Version -eq "3.7.17") {
35-
# Ensure Homebrew is installed (in case it's not already available)
36-
if (-not (Test-Path "/usr/local/bin/brew")) {
37-
Write-Host "Homebrew not found. Installing Homebrew..."
38-
Invoke-Expression -Command "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
39-
# Once Homebrew is installed, install the dependencies
40-
Write-Host "I 10000 nstalling dependencies: bzip2, readline, ncurses..."
41-
Execute-Command -Command "brew install bzip2 readline ncurses"
42-
43-
} else {
44-
Write-Host "Homebrew is already installed."
45-
}
46-
}
31+
32+
# Only for Python 3.7.17, install additional dependencies
33+
if ($this.Version -eq "3.7.17") {
34+
Write-Host "Installing additional dependencies for Python 3.7.17..."
35+
# Install necessary dependencies for Python 3.7.17
36+
Execute-Command -Command "brew install bzip2 zlib readline ncurses sqlite3 openssl@1.1"
37+
}
4738
}
4839

4940
[void] Configure() {
@@ -76,20 +67,22 @@ class macOSPythonBuilder : NixPythonBuilder {
7667
$env:LDFLAGS = "-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
7768
$env:CFLAGS = "-I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
7869
} else {
79-
$configureString += " --with-openssl=/usr/local/opt/openssl@3"
70+
$configureString += " --with-openssl=/usr/local/opt/openssl@1.1" # For Python 3.7.x, use OpenSSL 1.1
8071

81-
# 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
82-
# with the error: zipimport.ZipImportError: can't decompress data; zlib not available
72+
# For Python 3.7.2, 3.7.3, and 3.7.17 we need to provide PATH for zlib to pack it properly.
73+
# Otherwise, the build will fail with the error: zipimport.ZipImportError: can't decompress data; zlib not available
8374
if ($this.Version -eq "3.7.2" -or $this.Version -eq "3.7.3" -or $this.Version -eq "3.7.17") {
8475
$env:LDFLAGS = "-L/usr/local/opt/zlib/lib"
8576
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
8677
}
8778

8879
if ($this.Version -gt "3.7.12") {
8980
$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'"
90-
}
81+
}
9182

83+
# Specific for Python 3.7.17
9284
if ($this.Version -eq "3.7.17") {
85+
Write-Host "Setting environment for Python 3.7.17..."
9386
$env:LDFLAGS += " -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix ncurses)/lib"
9487
$env:CFLAGS += " -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix ncurses)/include"
9588
}

0 commit comments

Comments
 (0)
0