diff --git a/misc/build_wheel.py b/misc/build_wheel.py index b21c19da98eb..44b40c2e8fed 100644 --- a/misc/build_wheel.py +++ b/misc/build_wheel.py @@ -3,13 +3,11 @@ The main GitHub workflow where this script is used: https://github.com/mypyc/mypy_mypyc-wheels/blob/master/.github/workflows/build.yml -This uses cibuildwheel (https://github.com/pypa/cibuildwheel) to -build the wheels. +This uses cibuildwheel (https://github.com/pypa/cibuildwheel) to build the wheels. Usage: - build_wheel_ci.py --python-version \ - --output-dir + build_wheel.py --python-version --output-dir Wheels for the given Python version will be created in the given directory. Python version is in form "39". @@ -18,9 +16,7 @@ You can test locally by using --extra-opts. macOS example: - mypy/misc/build_wheel_ci.py --python-version 39 --output-dir out --extra-opts="--platform macos" - -Other supported values for platform: linux, windows + mypy/misc/build_wheel.py --python-version 39 --output-dir out --extra-opts="--platform macos" """ import argparse @@ -39,13 +35,13 @@ def create_environ(python_version: str) -> Dict[str, str]: """Set up environment variables for cibuildwheel.""" env = os.environ.copy() - env['CIBW_BUILD'] = "cp{}-*".format(python_version) + env['CIBW_BUILD'] = f"cp{python_version}-*" # Don't build 32-bit wheels env['CIBW_SKIP'] = "*-manylinux_i686 *-win32" # Apple Silicon support - # When cross-compiling on Intel, it is not possible to test arm64 and + # When cross-compiling on Intel, it is not possible to test arm64 and # the arm64 part of a universal2 wheel. Warnings will be silenced with # following CIBW_TEST_SKIP env['CIBW_ARCHS_MACOS'] = "x86_64 arm64" @@ -56,20 +52,15 @@ def create_environ(python_version: str) -> Dict[str, str]: # mypy's isolated builds don't specify the requirements mypyc needs, so install # requirements and don't use isolated builds. we need to use build-requirements.txt # with recent mypy commits to get stub packages needed for compilation. - # - # TODO: remove use of mypy-requirements.txt once we no longer need to support - # building pre modular typeshed releases env['CIBW_BEFORE_BUILD'] = """ - pip install -r {package}/mypy-requirements.txt && - (pip install -r {package}/build-requirements.txt || true) + pip install -r {package}/build-requirements.txt """.replace('\n', ' ') # 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) + pip install -r {package}/build-requirements.txt """.replace('\n', ' ') % LLVM_URL # the double negative is counterintuitive, https://github.com/pypa/pip/issues/5735 @@ -128,8 +119,7 @@ def main() -> None: output_dir = args.output_dir extra_opts = args.extra_opts environ = create_environ(python_version) - script = 'python -m cibuildwheel {} --output-dir {} {}'.format(extra_opts, output_dir, - ROOT_DIR) + script = f'python -m cibuildwheel {extra_opts} --output-dir {output_dir} {ROOT_DIR}' subprocess.check_call(script, shell=True, env=environ)