Rebuild MacOS python with lzma module installed (#975)
Also update `scripts/update_python.py` such that it works on linux once again. Fixes: https://github.com/emscripten-core/emscripten/issues/16073
This commit is contained in:
@@ -422,7 +422,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "python",
|
"id": "python",
|
||||||
"version": "3.9.2-1",
|
"version": "3.9.2",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"arch": "x86_64",
|
"arch": "x86_64",
|
||||||
"windows_url": "python-3.9.2-1-embed-amd64+pywin32.zip",
|
"windows_url": "python-3.9.2-1-embed-amd64+pywin32.zip",
|
||||||
@@ -431,16 +431,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "python",
|
"id": "python",
|
||||||
"version": "3.9.2-1",
|
"version": "3.9.2",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"arch": "x86_64",
|
"arch": "x86_64",
|
||||||
"macos_url": "python-3.9.2-1-macos-x86_64.tar.gz",
|
"macos_url": "python-3.9.2-2-macos-x86_64.tar.gz",
|
||||||
"activated_cfg": "PYTHON='%installation_dir%/bin/python3'",
|
"activated_cfg": "PYTHON='%installation_dir%/bin/python3'",
|
||||||
"activated_env": "EMSDK_PYTHON=%installation_dir%/bin/python3;SSL_CERT_FILE=%installation_dir%/lib/python3.9/site-packages/certifi/cacert.pem"
|
"activated_env": "EMSDK_PYTHON=%installation_dir%/bin/python3;SSL_CERT_FILE=%installation_dir%/lib/python3.9/site-packages/certifi/cacert.pem"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "python",
|
"id": "python",
|
||||||
"version": "3.9.2-1",
|
"version": "3.9.2",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"macos_url": "python-3.9.2-1-macos-arm64.tar.gz",
|
"macos_url": "python-3.9.2-1-macos-arm64.tar.gz",
|
||||||
@@ -644,13 +644,13 @@
|
|||||||
{
|
{
|
||||||
"version": "upstream-main",
|
"version": "upstream-main",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"uses": ["python-3.9.2-1-64bit", "llvm-git-main-64bit", "node-14.18.2-64bit", "emscripten-main-64bit", "binaryen-main-64bit"],
|
"uses": ["python-3.9.2-64bit", "llvm-git-main-64bit", "node-14.18.2-64bit", "emscripten-main-64bit", "binaryen-main-64bit"],
|
||||||
"os": "win"
|
"os": "win"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version": "upstream-main",
|
"version": "upstream-main",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"uses": ["python-3.9.2-1-64bit", "llvm-git-main-64bit", "node-14.18.2-64bit", "emscripten-main-64bit", "binaryen-main-64bit"],
|
"uses": ["python-3.9.2-64bit", "llvm-git-main-64bit", "node-14.18.2-64bit", "emscripten-main-64bit", "binaryen-main-64bit"],
|
||||||
"os": "macos"
|
"os": "macos"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -711,7 +711,7 @@
|
|||||||
{
|
{
|
||||||
"version": "releases-upstream-%releases-tag%",
|
"version": "releases-upstream-%releases-tag%",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"uses": ["node-14.18.2-64bit", "python-3.9.2-1-64bit", "releases-upstream-%releases-tag%-64bit"],
|
"uses": ["node-14.18.2-64bit", "python-3.9.2-64bit", "releases-upstream-%releases-tag%-64bit"],
|
||||||
"os": "macos",
|
"os": "macos",
|
||||||
"arch": "x86_64",
|
"arch": "x86_64",
|
||||||
"custom_install_script": "emscripten_npm_install"
|
"custom_install_script": "emscripten_npm_install"
|
||||||
@@ -719,7 +719,7 @@
|
|||||||
{
|
{
|
||||||
"version": "releases-upstream-%releases-tag%",
|
"version": "releases-upstream-%releases-tag%",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"uses": ["node-14.18.2-64bit", "python-3.9.2-1-64bit", "releases-upstream-%releases-tag%-64bit"],
|
"uses": ["node-14.18.2-64bit", "python-3.9.2-64bit", "releases-upstream-%releases-tag%-64bit"],
|
||||||
"os": "macos",
|
"os": "macos",
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"custom_install_script": "emscripten_npm_install"
|
"custom_install_script": "emscripten_npm_install"
|
||||||
@@ -727,7 +727,7 @@
|
|||||||
{
|
{
|
||||||
"version": "releases-upstream-%releases-tag%",
|
"version": "releases-upstream-%releases-tag%",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"uses": ["node-14.18.2-64bit", "python-3.9.2-1-64bit", "java-8.152-64bit", "releases-upstream-%releases-tag%-64bit"],
|
"uses": ["node-14.18.2-64bit", "python-3.9.2-64bit", "java-8.152-64bit", "releases-upstream-%releases-tag%-64bit"],
|
||||||
"os": "win",
|
"os": "win",
|
||||||
"custom_install_script": "emscripten_npm_install"
|
"custom_install_script": "emscripten_npm_install"
|
||||||
},
|
},
|
||||||
@@ -749,7 +749,7 @@
|
|||||||
{
|
{
|
||||||
"version": "releases-fastcomp-%releases-tag%",
|
"version": "releases-fastcomp-%releases-tag%",
|
||||||
"bitness": 64,
|
"bitness": 64,
|
||||||
"uses": ["node-14.18.2-64bit", "python-3.9.2-1-64bit", "releases-fastcomp-%releases-tag%-64bit"],
|
"uses": ["node-14.18.2-64bit", "python-3.9.2-64bit", "releases-fastcomp-%releases-tag%-64bit"],
|
||||||
"os": "macos",
|
"os": "macos",
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"custom_install_script": "emscripten_npm_install"
|
"custom_install_script": "emscripten_npm_install"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ from subprocess import check_call
|
|||||||
version = '3.9.2'
|
version = '3.9.2'
|
||||||
major_minor_version = '.'.join(version.split('.')[:2]) # e.g. '3.9.2' -> '3.9'
|
major_minor_version = '.'.join(version.split('.')[:2]) # e.g. '3.9.2' -> '3.9'
|
||||||
base = 'https://www.python.org/ftp/python/%s/' % version
|
base = 'https://www.python.org/ftp/python/%s/' % version
|
||||||
revision = '1'
|
revision = '2'
|
||||||
|
|
||||||
pywin32_version = '227'
|
pywin32_version = '227'
|
||||||
pywin32_base = 'https://github.com/mhammond/pywin32/releases/download/b%s/' % pywin32_version
|
pywin32_base = 'https://github.com/mhammond/pywin32/releases/download/b%s/' % pywin32_version
|
||||||
@@ -105,7 +105,7 @@ def build_python():
|
|||||||
if sys.platform.startswith('darwin'):
|
if sys.platform.startswith('darwin'):
|
||||||
osname = 'macos'
|
osname = 'macos'
|
||||||
# Take some rather drastic steps to link openssl statically
|
# Take some rather drastic steps to link openssl statically
|
||||||
check_call(['brew', 'install', 'openssl', 'pkg-config'])
|
check_call(['brew', 'install', 'openssl', 'xz', 'pkg-config'])
|
||||||
if platform.machine() == 'x86_64':
|
if platform.machine() == 'x86_64':
|
||||||
prefix = '/usr/local'
|
prefix = '/usr/local'
|
||||||
min_macos_version = '10.11'
|
min_macos_version = '10.11'
|
||||||
@@ -113,11 +113,14 @@ def build_python():
|
|||||||
prefix = '/opt/homebrew'
|
prefix = '/opt/homebrew'
|
||||||
min_macos_version = '11.0'
|
min_macos_version = '11.0'
|
||||||
|
|
||||||
osname += '-' + platform.machine() # Append '-x86_64' or '-arm64' depending on current arch. (TODO: Do this for Linux too, move this below?)
|
# Append '-x86_64' or '-arm64' depending on current arch. (TODO: Do
|
||||||
|
# this for Linux too, move this below?)
|
||||||
|
osname += '-' + platform.machine()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(os.path.join(prefix, 'opt', 'openssl', 'lib', 'libssl.dylib'))
|
os.remove(os.path.join(prefix, 'opt', 'openssl', 'lib', 'libssl.dylib'))
|
||||||
os.remove(os.path.join(prefix, 'opt', 'openssl', 'lib', 'libcrypto.dylib'))
|
os.remove(os.path.join(prefix, 'opt', 'openssl', 'lib', 'libcrypto.dylib'))
|
||||||
|
os.remove(os.path.join(prefix, 'opt', 'xz', 'lib', 'liblzma.dylib'))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
os.environ['PKG_CONFIG_PATH'] = os.path.join(prefix, 'opt', 'openssl', 'lib', 'pkgconfig')
|
os.environ['PKG_CONFIG_PATH'] = os.path.join(prefix, 'opt', 'openssl', 'lib', 'pkgconfig')
|
||||||
@@ -129,11 +132,18 @@ def build_python():
|
|||||||
check_call(['git', 'clone', 'https://github.com/python/cpython'])
|
check_call(['git', 'clone', 'https://github.com/python/cpython'])
|
||||||
check_call(['git', 'checkout', 'v' + version], cwd=src_dir)
|
check_call(['git', 'checkout', 'v' + version], cwd=src_dir)
|
||||||
|
|
||||||
min_macos_version_line = '-mmacosx-version-min=' + min_macos_version # Specify the min OS version we want the build to work on
|
env = os.environ
|
||||||
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
|
if sys.platform.startswith('darwin'):
|
||||||
env = os.environ.copy()
|
# Specify the min OS version we want the build to work on
|
||||||
env['MACOSX_DEPLOYMENT_TARGET'] = min_macos_version
|
min_macos_version_line = '-mmacosx-version-min=' + min_macos_version
|
||||||
check_call(['./configure', 'CFLAGS=' + build_flags, 'CXXFLAGS=' + build_flags, 'LDFLAGS=' + min_macos_version_line], cwd=src_dir, env=env)
|
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
|
||||||
|
env = env.copy()
|
||||||
|
env['MACOSX_DEPLOYMENT_TARGET'] = min_macos_version
|
||||||
|
configure_args = ['CFLAGS=' + build_flags, 'CXXFLAGS=' + build_flags, 'LDFLAGS=' + min_macos_version_line]
|
||||||
|
else:
|
||||||
|
configure_args = []
|
||||||
|
check_call(['./configure'] + configure_args, cwd=src_dir, env=env)
|
||||||
check_call(['make', '-j', str(multiprocessing.cpu_count())], cwd=src_dir, env=env)
|
check_call(['make', '-j', str(multiprocessing.cpu_count())], cwd=src_dir, env=env)
|
||||||
check_call(['make', 'install', 'DESTDIR=install'], cwd=src_dir, env=env)
|
check_call(['make', 'install', 'DESTDIR=install'], cwd=src_dir, env=env)
|
||||||
|
|
||||||
@@ -143,6 +153,7 @@ def build_python():
|
|||||||
# SSL certificates are available (certifi in installed and used by requests).
|
# SSL certificates are available (certifi in installed and used by requests).
|
||||||
pybin = os.path.join(src_dir, 'install', 'usr', 'local', 'bin', 'python3')
|
pybin = os.path.join(src_dir, 'install', 'usr', 'local', 'bin', 'python3')
|
||||||
pip = os.path.join(src_dir, 'install', 'usr', 'local', 'bin', 'pip3')
|
pip = os.path.join(src_dir, 'install', 'usr', 'local', 'bin', 'pip3')
|
||||||
|
check_call([pybin, '-m', 'ensurepip', '--upgrade'])
|
||||||
check_call([pybin, pip, 'install', 'requests'])
|
check_call([pybin, pip, 'install', 'requests'])
|
||||||
|
|
||||||
dirname = 'python-%s-%s' % (version, revision)
|
dirname = 'python-%s-%s' % (version, revision)
|
||||||
@@ -154,7 +165,7 @@ def build_python():
|
|||||||
shutil.rmtree(os.path.join(dirname, 'lib', 'python' + major_minor_version, 'test'))
|
shutil.rmtree(os.path.join(dirname, 'lib', 'python' + major_minor_version, 'test'))
|
||||||
shutil.rmtree(os.path.join(dirname, 'include'))
|
shutil.rmtree(os.path.join(dirname, 'include'))
|
||||||
for lib in glob.glob(os.path.join(dirname, 'lib', 'lib*.a')):
|
for lib in glob.glob(os.path.join(dirname, 'lib', 'lib*.a')):
|
||||||
os.remove(lib)
|
os.remove(lib)
|
||||||
check_call(['tar', 'zcvf', tarball, dirname])
|
check_call(['tar', 'zcvf', tarball, dirname])
|
||||||
print('Uploading: ' + upload_base + tarball)
|
print('Uploading: ' + upload_base + tarball)
|
||||||
check_call(['gsutil', 'cp', '-n', tarball, upload_base + tarball])
|
check_call(['gsutil', 'cp', '-n', tarball, upload_base + tarball])
|
||||||
|
|||||||
Reference in New Issue
Block a user