2424import subprocess
2525from 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
3128ROOT_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,30 +49,24 @@ 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 [
56- "CIBW_BEFORE_BUILD"
57- ] = """
58- pip install -r {package}/build-requirements.txt
59- """ .replace (
60- "\n " , " "
61- )
52+ env ["CIBW_BEFORE_BUILD" ] = "pip install -r {package}/build-requirements.txt"
6253
63- # download a copy of clang to use to compile on linux. this was probably built in 2018,
64- # speeds up compilation 2x
65- env ["CIBW_BEFORE_BUILD_LINUX" ] = (
66- """
67- (cd / && curl -L %s | tar xzf -) &&
68- pip install -r {package}/build-requirements.txt
69- """ .replace (
70- "\n " , " "
71- )
72- % LLVM_URL
73- )
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 [
58+ "CIBW_BEFORE_ALL_LINUX"
59+ ] = "command -v yum && yum install -y llvm-toolset-7.0 || apk add --no-cache clang"
7460
7561 # the double negative is counterintuitive, https://github.com/pypa/pip/issues/5735
62+ # add llvm paths to environment to eliminate scl usage (like manylinux image does for gcc toolset).
63+ # specifying redhat paths for musllinux shouldn't harm but is not desired (see overrides-related comment above).
7664 env ["CIBW_ENVIRONMENT" ] = "MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no"
7765 env ["CIBW_ENVIRONMENT_LINUX" ] = (
78- "MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no " + "CC=/opt/llvm/bin/clang"
66+ "MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no "
67+ + "PATH=$PATH:/opt/rh/llvm-toolset-7.0/root/usr/bin "
68+ + "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/llvm-toolset-7.0/root/usr/lib64 "
69+ + "CC=clang"
7970 )
8071 env [
8172 "CIBW_ENVIRONMENT_WINDOWS"
0 commit comments