Skip to content

Commit 0a9aad6

Browse files
committed
Add musllinux wheel support, Use 'official' llvm build for compilation
1 parent b0e59b2 commit 0a9aad6

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

misc/build_wheel.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
import subprocess
2525
from typing import Dict
2626

27-
# Clang package we use on Linux
28-
LLVM_URL = 'https://github.com/mypyc/mypy_mypyc-wheels/releases/download/llvm/llvm-centos-5.tar.gz'
29-
3027
# Mypy repository root
3128
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
3229

@@ -38,7 +35,7 @@ def create_environ(python_version: str) -> Dict[str, str]:
3835
env['CIBW_BUILD'] = f"cp{python_version}-*"
3936

4037
# Don't build 32-bit wheels
41-
env['CIBW_SKIP'] = "*-manylinux_i686 *-win32 *-musllinux_*"
38+
env['CIBW_SKIP'] = "*-manylinux_i686 *-musllinux_i686 *-win32"
4239

4340
# Apple Silicon support
4441
# When cross-compiling on Intel, it is not possible to test arm64 and
@@ -52,22 +49,22 @@ def create_environ(python_version: str) -> Dict[str, str]:
5249
# mypy's isolated builds don't specify the requirements mypyc needs, so install
5350
# requirements and don't use isolated builds. we need to use build-requirements.txt
5451
# with recent mypy commits to get stub packages needed for compilation.
55-
env['CIBW_BEFORE_BUILD'] = """
56-
pip install -r {package}/build-requirements.txt
57-
""".replace('\n', ' ')
52+
env['CIBW_BEFORE_BUILD'] = 'pip install -r {package}/build-requirements.txt'
5853

59-
# download a copy of clang to use to compile on linux. this was probably built in 2018,
60-
# speeds up compilation 2x
61-
env['CIBW_BEFORE_BUILD_LINUX'] = """
62-
(cd / && curl -L %s | tar xzf -) &&
63-
pip install -r {package}/build-requirements.txt
64-
""".replace('\n', ' ') % LLVM_URL
54+
# install clang using available package manager. platform-specific configuration overrides is only possible with
55+
# pyproject.toml. once project fully transitions, properly adjust cibuildwheel configuration to each platform.
56+
# https://cibuildwheel.readthedocs.io/en/stable/options/#overrides
57+
env['CIBW_BEFORE_ALL_LINUX'] = 'command -v yum && yum install -y llvm-toolset-7.0 || apk add --no-cache clang'
6558

6659
# the double negative is counterintuitive, https://github.com/pypa/pip/issues/5735
60+
# add llvm paths to environment to eliminate scl usage (like manylinux image does for gcc toolset).
61+
# specifying redhat paths for musllinux shouldn't harm but is not desired (see overrides-related comment above).
6762
env['CIBW_ENVIRONMENT'] = 'MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no'
6863
env['CIBW_ENVIRONMENT_LINUX'] = (
6964
'MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no ' +
70-
'CC=/opt/llvm/bin/clang'
65+
'PATH=$PATH:/opt/rh/llvm-toolset-7.0/root/usr/bin ' +
66+
'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/llvm-toolset-7.0/root/usr/lib64 ' +
67+
'CC=clang'
7168
)
7269
env['CIBW_ENVIRONMENT_WINDOWS'] = (
7370
'MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=2 PIP_NO_BUILD_ISOLATION=no'

0 commit comments

Comments
 (0)