1
- using module " ./nix-python-builder.psm1"
2
-
3
1
class macOSPythonBuilder : NixPythonBuilder {
4
2
<#
5
3
. SYNOPSIS
6
4
MacOS Python builder class.
7
5
8
6
. 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.
10
8
11
9
While python.org provides precompiled binaries for macOS, switching to them risks breaking existing customers.
12
10
If we wanted to start using the official binaries instead of building from source, we should avoid changing previous versions
13
11
so we remain backwards compatible.
14
12
15
13
. 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.
17
15
18
16
. PARAMETER version
19
17
The version of Python that should be built.
20
-
21
18
#>
22
19
23
20
macOSPythonBuilder(
@@ -31,19 +28,13 @@ class macOSPythonBuilder : NixPythonBuilder {
31
28
. SYNOPSIS
32
29
Prepare system environment by installing dependencies and required packages.
33
30
#>
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
+ }
47
38
}
48
39
49
40
[void ] Configure() {
@@ -76,20 +67,22 @@ class macOSPythonBuilder : NixPythonBuilder {
76
67
$env: LDFLAGS = " -L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
77
68
$env: CFLAGS = " -I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
78
69
} 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
80
71
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
83
74
if ($this.Version -eq " 3.7.2" -or $this.Version -eq " 3.7.3" -or $this.Version -eq " 3.7.17" ) {
84
75
$env: LDFLAGS = " -L/usr/local/opt/zlib/lib"
85
76
$env: CFLAGS = " -I/usr/local/opt/zlib/include"
86
77
}
87
78
88
79
if ($this.Version -gt " 3.7.12" ) {
89
80
$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
+ }
91
82
83
+ # Specific for Python 3.7.17
92
84
if ($this.Version -eq " 3.7.17" ) {
85
+ Write-Host " Setting environment for Python 3.7.17..."
93
86
$env: LDFLAGS += " -L$ ( brew -- prefix bzip2) /lib -L$ ( brew -- prefix readline) /lib -L$ ( brew -- prefix ncurses) /lib"
94
87
$env: CFLAGS += " -I$ ( brew -- prefix bzip2) /include -I$ ( brew -- prefix readline) /include -I$ ( brew -- prefix ncurses) /include"
95
88
}
0 commit comments