Skip to content

Commit d308210

Browse files
authored
Use a 64-bit C compiler on Windows to build wheels (#10097)
This will hopefully fix out of memory errors. Work on #10074.
1 parent 09bc50f commit d308210

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

misc/build_wheel.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
# Clang package we use on Linux
3333
LLVM_URL = 'https://github.com/mypyc/mypy_mypyc-wheels/releases/download/llvm/llvm-centos-5.tar.gz'
3434

35+
# Script to configure 64-bit MSVC compiler executable
36+
VCVARS64 = (
37+
r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise' +
38+
r'\VC\Auxiliary\Build\vcvars64.bat'
39+
)
40+
3541
# Mypy repository root
3642
ROOT_DIR = os.path.dirname(os.path.dirname(__file__))
3743

@@ -53,18 +59,22 @@ def create_environ(python_version: str) -> Dict[str, str]:
5359
#
5460
# TODO: remove use of mypy-requirements.txt once we no longer need to support
5561
# building pre modular typeshed releases
56-
env['CIBW_BEFORE_BUILD'] = """
62+
install_deps = """
5763
pip install -r {package}/mypy-requirements.txt &&
5864
(pip install -r {package}/build-requirements.txt || true)
5965
""".replace('\n', ' ')
66+
env['CIBW_BEFORE_BUILD'] = install_deps
6067

6168
# download a copy of clang to use to compile on linux. this was probably built in 2018,
6269
# speeds up compilation 2x
63-
env['CIBW_BEFORE_BUILD_LINUX'] = """
64-
(cd / && curl -L %s | tar xzf -) &&
65-
pip install -r {package}/mypy-requirements.txt &&
66-
(pip install -r {package}/build-requirements.txt || true)
67-
""".replace('\n', ' ') % LLVM_URL
70+
env['CIBW_BEFORE_BUILD_LINUX'] = (
71+
"(cd / && curl -L %s | tar xzf -) && %s" % (LLVM_URL, install_deps)
72+
)
73+
74+
# IMPORTANT: The build can run out of memory if we don't use a 64-bit compiler on Windows.
75+
env['CIBW_BEFORE_BUILD_WINDOWS'] = (
76+
'call "%s" && %s' % (VCVARS64, install_deps)
77+
)
6878

6979
# the double negative is counterintuitive, https://github.com/pypa/pip/issues/5735
7080
env['CIBW_ENVIRONMENT'] = 'MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no'

0 commit comments

Comments
 (0)