34
34
version = '3.9.2'
35
35
major_minor_version = '.' .join (version .split ('.' )[:2 ]) # e.g. '3.9.2' -> '3.9'
36
36
base = 'https://www.python.org/ftp/python/%s/' % version
37
- revision = '1 '
37
+ revision = '2 '
38
38
39
39
pywin32_version = '227'
40
40
pywin32_base = 'https://github.com/mhammond/pywin32/releases/download/b%s/' % pywin32_version
@@ -105,19 +105,22 @@ def build_python():
105
105
if sys .platform .startswith ('darwin' ):
106
106
osname = 'macos'
107
107
# Take some rather drastic steps to link openssl statically
108
- check_call (['brew' , 'install' , 'openssl' , 'pkg-config' ])
108
+ check_call (['brew' , 'install' , 'openssl' , 'xz' , ' pkg-config' ])
109
109
if platform .machine () == 'x86_64' :
110
110
prefix = '/usr/local'
111
111
min_macos_version = '10.11'
112
112
elif platform .machine () == 'arm64' :
113
113
prefix = '/opt/homebrew'
114
114
min_macos_version = '11.0'
115
115
116
- osname += '-' + platform .machine () # Append '-x86_64' or '-arm64' depending on current arch. (TODO: Do this for Linux too, move this below?)
116
+ # Append '-x86_64' or '-arm64' depending on current arch. (TODO: Do
117
+ # this for Linux too, move this below?)
118
+ osname += '-' + platform .machine ()
117
119
118
120
try :
119
121
os .remove (os .path .join (prefix , 'opt' , 'openssl' , 'lib' , 'libssl.dylib' ))
120
122
os .remove (os .path .join (prefix , 'opt' , 'openssl' , 'lib' , 'libcrypto.dylib' ))
123
+ os .remove (os .path .join (prefix , 'opt' , 'xz' , 'lib' , 'liblzma.dylib' ))
121
124
except Exception :
122
125
pass
123
126
os .environ ['PKG_CONFIG_PATH' ] = os .path .join (prefix , 'opt' , 'openssl' , 'lib' , 'pkgconfig' )
@@ -129,11 +132,18 @@ def build_python():
129
132
check_call (['git' , 'clone' , 'https://github.com/python/cpython' ])
130
133
check_call (['git' , 'checkout' , 'v' + version ], cwd = src_dir )
131
134
132
- min_macos_version_line = '-mmacosx-version-min=' + min_macos_version # Specify the min OS version we want the build to work on
133
- build_flags = min_macos_version_line + ' -Werror=partial-availability' # Build against latest SDK, but issue an error if using any API that would not work on the min OS version
134
- env = os .environ .copy ()
135
- env ['MACOSX_DEPLOYMENT_TARGET' ] = min_macos_version
136
- check_call (['./configure' , 'CFLAGS=' + build_flags , 'CXXFLAGS=' + build_flags , 'LDFLAGS=' + min_macos_version_line ], cwd = src_dir , env = env )
135
+ env = os .environ
136
+ if sys .platform .startswith ('darwin' ):
137
+ # Specify the min OS version we want the build to work on
138
+ min_macos_version_line = '-mmacosx-version-min=' + min_macos_version
139
+ build_flags = min_macos_version_line + ' -Werror=partial-availability'
140
+ # Build against latest SDK, but issue an error if using any API that would not work on the min OS version
141
+ env = env .copy ()
142
+ env ['MACOSX_DEPLOYMENT_TARGET' ] = min_macos_version
143
+ configure_args = ['CFLAGS=' + build_flags , 'CXXFLAGS=' + build_flags , 'LDFLAGS=' + min_macos_version_line ]
144
+ else :
145
+ configure_args = []
146
+ check_call (['./configure' ] + configure_args , cwd = src_dir , env = env )
137
147
check_call (['make' , '-j' , str (multiprocessing .cpu_count ())], cwd = src_dir , env = env )
138
148
check_call (['make' , 'install' , 'DESTDIR=install' ], cwd = src_dir , env = env )
139
149
@@ -143,6 +153,7 @@ def build_python():
143
153
# SSL certificates are available (certifi in installed and used by requests).
144
154
pybin = os .path .join (src_dir , 'install' , 'usr' , 'local' , 'bin' , 'python3' )
145
155
pip = os .path .join (src_dir , 'install' , 'usr' , 'local' , 'bin' , 'pip3' )
156
+ check_call ([pybin , '-m' , 'ensurepip' , '--upgrade' ])
146
157
check_call ([pybin , pip , 'install' , 'requests' ])
147
158
148
159
dirname = 'python-%s-%s' % (version , revision )
@@ -154,7 +165,7 @@ def build_python():
154
165
shutil .rmtree (os .path .join (dirname , 'lib' , 'python' + major_minor_version , 'test' ))
155
166
shutil .rmtree (os .path .join (dirname , 'include' ))
156
167
for lib in glob .glob (os .path .join (dirname , 'lib' , 'lib*.a' )):
157
- os .remove (lib )
168
+ os .remove (lib )
158
169
check_call (['tar' , 'zcvf' , tarball , dirname ])
159
170
print ('Uploading: ' + upload_base + tarball )
160
171
check_call (['gsutil' , 'cp' , '-n' , tarball , upload_base + tarball ])
0 commit comments