From e7217d62036cfe5cb34ab9fa90b093749789c3b4 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Tue, 16 Feb 2021 13:45:21 +0000 Subject: [PATCH] Use a 64-bit C compiler on Windows to build wheels This will hopefully fix out of memory errors. Work on #10074. --- misc/build_wheel.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/misc/build_wheel.py b/misc/build_wheel.py index 13633405bf774..11b867980c6a7 100644 --- a/misc/build_wheel.py +++ b/misc/build_wheel.py @@ -32,6 +32,12 @@ # Clang package we use on Linux LLVM_URL = 'https://github.com/mypyc/mypy_mypyc-wheels/releases/download/llvm/llvm-centos-5.tar.gz' +# Script to configure 64-bit MSVC compiler executable +VCVARS64 = ( + r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise' + + r'\VC\Auxiliary\Build\vcvars64.bat' +) + # Mypy repository root ROOT_DIR = os.path.dirname(os.path.dirname(__file__)) @@ -53,18 +59,22 @@ def create_environ(python_version: str) -> Dict[str, str]: # # TODO: remove use of mypy-requirements.txt once we no longer need to support # building pre modular typeshed releases - env['CIBW_BEFORE_BUILD'] = """ + install_deps = """ pip install -r {package}/mypy-requirements.txt && (pip install -r {package}/build-requirements.txt || true) """.replace('\n', ' ') + env['CIBW_BEFORE_BUILD'] = install_deps # download a copy of clang to use to compile on linux. this was probably built in 2018, # speeds up compilation 2x - env['CIBW_BEFORE_BUILD_LINUX'] = """ - (cd / && curl -L %s | tar xzf -) && - pip install -r {package}/mypy-requirements.txt && - (pip install -r {package}/build-requirements.txt || true) - """.replace('\n', ' ') % LLVM_URL + env['CIBW_BEFORE_BUILD_LINUX'] = ( + "(cd / && curl -L %s | tar xzf -) && %s" % (LLVM_URL, install_deps) + ) + + # IMPORTANT: The build can run out of memory if we don't use a 64-bit compiler on Windows. + env['CIBW_BEFORE_BUILD_WINDOWS'] = ( + 'call "%s" && %s' % (VCVARS64, install_deps) + ) # the double negative is counterintuitive, https://github.com/pypa/pip/issues/5735 env['CIBW_ENVIRONMENT'] = 'MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=3 PIP_NO_BUILD_ISOLATION=no'