From 1ded625f0f1f3ee715bdf0c60480ad2ac382ae0c Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Thu, 1 Oct 2026 13:32:09 +0200 Subject: [PATCH] wheels: fix cmake argument passing - use CIBW_CONFIG_SETTINGS to pass cmake options - disable homebrew for wheel build - bison is set explicitly - update cmake option parsing to use shlex so multiple arguments can be provided - use common CIBW environment (MACOSX_DEPLOYMENT_TARGET has no effect on linux) --- .github/workflows/wheels.yml | 8 ++------ pyosys/build/local_backend.py | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8db8043c0..6aff2d73c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -91,17 +91,13 @@ jobs: CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 CIBW_BEFORE_ALL: bash ./.github/workflows/wheels/cibw_before_all.sh + CIBW_CONFIG_SETTINGS: > + cmake="-DCMAKE_BUILD_TYPE=Release -DYOSYS_ENABLE_HOMEBREW:BOOL=OFF" CIBW_ENVIRONMENT: > OPTFLAGS=-O3 PKG_CONFIG_PATH={project}/ffi/pfx/lib/pkgconfig PATH="{project}/bison/src:$PATH" - CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release" - CIBW_ENVIRONMENT_MACOS: > - OPTFLAGS=-O3 - PKG_CONFIG_PATH={project}/ffi/pfx/lib/pkgconfig MACOSX_DEPLOYMENT_TARGET=11 - PATH="{project}/bison/src:$PATH" - CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release" CIBW_BEFORE_BUILD: bash ./.github/workflows/wheels/cibw_before_build.sh CIBW_TEST_COMMAND: python3 {project}/tests/pyosys/run_tests.py - uses: actions/upload-artifact@v7 diff --git a/pyosys/build/local_backend.py b/pyosys/build/local_backend.py index 8303eefab..0f5f61e51 100644 --- a/pyosys/build/local_backend.py +++ b/pyosys/build/local_backend.py @@ -1,11 +1,12 @@ -# To build a wheel with additional CMake options, use `--build-option`, e.g.: +# To build a wheel with additional CMake options, use `-C/--config-settings`, e.g.: # -# python -m build -w -Ccmake=-DYOSYS_COMPILER_LAUNCHER=ccache -# pip install -Ccmake=-DYOSYS_COMPILER_LAUNCHER=ccache . +# python -m build -w -Ccmake="-DYOSYS_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release" +# pip install -Ccmake="-DYOSYS_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release". import re import os import sys +import shlex import pathlib import tarfile import tempfile @@ -57,23 +58,26 @@ PLATFORM_TAG = PLATFORM_TAG_RAW.lower().replace("-", "_").replace(".", "_").repl COMPAT_TAG = f"{PYTHON_TAG}-{ABI_TAG}-{PLATFORM_TAG}" -def compile_pyosys(cmake_options=[], parallel=os.cpu_count() or 1): +def compile_pyosys(cmake_options=None, parallel=os.cpu_count() or 1): install_dir = tempfile.TemporaryDirectory(prefix="pyosys_install") with tempfile.TemporaryDirectory(prefix="pyosys_build") as build_dir: subprocess.check_call([ "cmake", "-S", ".", "-B", build_dir, - "-DCMAKE_BUILD_TYPE=Release", - f"-DPython3_EXECUTABLE={sys.executable}", - "-DYOSYS_WITH_PYTHON=ON", - "-DYOSYS_INSTALL_DRIVER=OFF", - "-DYOSYS_INSTALL_LIBRARY=OFF", - "-DYOSYS_INSTALL_PYTHON=ON", f"-DCMAKE_INSTALL_PREFIX={install_dir.name}", f"-DYOSYS_INSTALL_PYTHON_SITEDIR=python", - "-DYOSYS_BUILD_PYTHON_ONLY=ON", - *cmake_options, + # Build Pyosys and only Pyosys + f"-DPython3_EXECUTABLE={sys.executable}", + "-DYOSYS_WITH_PYTHON:BOOL=ON", + "-DYOSYS_INSTALL_DRIVER:BOOL=OFF", + "-DYOSYS_INSTALL_LIBRARY:BOOL=OFF", + "-DYOSYS_INSTALL_PYTHON:BOOL=ON", + "-DYOSYS_BUILD_PYTHON_ONLY:BOOL=ON", + # Tcl interpreter not very useful when only building libyosys + "-DYOSYS_WITHOUT_TCL:BOOL=ON", + # Extra options + *(cmake_options or []), *MACOSX_DEPLOYMENT_TARGET_FLAGS, ]) subprocess.check_call([ @@ -168,7 +172,7 @@ def build_wheel(wheel_dir, config_settings=None, metadata_directory=None): if config_settings is not None: if cmake_options := config_settings.get("cmake", cmake_options): if isinstance(cmake_options, str): - cmake_options = [cmake_options] + cmake_options = shlex.split(cmake_options) with compile_pyosys(cmake_options) as install_dir: wheel.write_files(pathlib.Path(install_dir) / "python")