From 895dfeaeea976d6272080bc76abc32026d44f5f7 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Fri, 13 Sep 2024 13:07:13 +0530 Subject: [PATCH] CI: fix wheels build - Remove python 3.8 wheels and add python 3.13 wheels - download_dlls: remove types and update to 1.54.0-v2 - Use prebuilt libraries for macOS - update actions --- .github/workflows/build.yml | 92 ++++++++++++++++----------------- .gitignore | 1 + packing/download_dlls.py | 8 +-- packing/download_pango_macos.py | 67 ++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 52 deletions(-) create mode 100644 packing/download_pango_macos.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d94769c3..bcfd1b67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,63 +16,53 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-11, windows-2019] - bitness: [32, 64] include: # Run 32 and 64 bit version in parallel for Windows - - os: windows-2019 - bitness: 64 + - os: windows-2022 platform_id: win_amd64 - - os: windows-2019 - bitness: 32 + architecture: x64 + - os: windows-2022 platform_id: win32 - - os: macos-11 - bitness: 64 + architecture: x86 + - os: macos-13 platform_id: macosx_x86_64 - exclude: - - os: macos-11 - bitness: 32 + architecture: x64 + - os: macos-14 + platform_id: macosx_arm64 + architecture: arm64 env: - CIBW_BUILD: cp38-${{ matrix.platform_id }} cp39-${{ matrix.platform_id }} cp310-${{ matrix.platform_id }} cp311-${{ matrix.platform_id }} cp312-${{ matrix.platform_id }} - CIBW_SKIP: pp* cp35* cp36* cp37* - CIBW_BEFORE_BUILD_MACOS: "source packing/build_pango_mac.sh" + CIBW_BUILD: cp39-${{ matrix.platform_id }} cp310-${{ matrix.platform_id }} cp311-${{ matrix.platform_id }} cp312-${{ matrix.platform_id }} cp313-${{ matrix.platform_id }} + CIBW_SKIP: pp* cp36* cp37* cp38* + CIBW_BEFORE_BUILD_MACOS: "python packing/download_pango_macos.py ${{ matrix.architecture }}" CIBW_BEFORE_BUILD_WINDOWS: "python packing/download_dlls.py" CIBW_ENVIRONMENT_WINDOWS: "PKG_CONFIG_PATH='C:\\cibw\\vendor\\lib\\pkgconfig'" CIBW_ENVIRONMENT_MACOS: "PKG_CONFIG_PATH='/Users/runner/pangobuild/lib/pkgconfig'" - CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python packing/inject-dlls.py {wheel} {dest_dir} C:\cibw\vendor\bin CIBW_TEST_REQUIRES: pytest pytest-cov CIBW_TEST_COMMAND: "bash {project}/packing/test_wheels.sh {project}" steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - name: Install Python - with: - python-version: "3.8" - - - name: Install cibuildwheel - env: - event_name: ${{ github.event_name }} - continue-on-error: true - shell: bash + - uses: actions/checkout@v4 + - name: Set Path for pkg-config + if: runner.os == 'windows' run: | - python -m pip install cibuildwheel==2.16.1 - echo "$event_name" + $env:Path = "C:\cibw\pkg-config\bin;C:\cibw\vendor\bin;$($env:PATH)" + echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Build wheels (Windows) if: runner.os == 'windows' + shell: pwsh run: | - $ErrorActionPreference = 'Stop' - $env:PATH="$env:PATH;C:\cibw\pkg-config\bin" - $env:PKG_CONFIG_PATH="C:\cibw\vendor\lib\pkgconfig" Copy-Item packing/LICENSE.bin . Rename-Item LICENSE.bin LICENSE.win32 - python -m cibuildwheel --output-dir wheelhouse - name: Build wheels (Non-Windows) if: runner.os != 'windows' run: | cp packing/LICENSE.bin . - python -m cibuildwheel --output-dir wheelhouse + + - name: Build wheels + uses: pypa/cibuildwheel@v2.20.0 + env: + PKG_CONFIG_PATH: "C:\\cibw\\vendor\\lib\\pkgconfig" - uses: actions/upload-artifact@v3 with: @@ -86,26 +76,32 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-11, windows-2019] - architecture: [x86, x64] - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + os: [windows-2022, macos-13, macos-14] include: - - os: windows-2019 - architecture: x64 + - os: windows-2022 platform_id: win_amd64 - - os: windows-2019 - architecture: x86 - platform_id: win32 - - os: macos-11 architecture: x64 - platform_id: macosx_x86_64 - exclude: - - os: macos-11 + - os: windows-2022 + platform_id: win32 architecture: x86 + - os: macos-13 + platform_id: macosx_x86_64 + architecture: x86_64 + - os: macos-14 + platform_id: macosx_arm64 + architecture: arm64 + + # include: [ + # {os: windows-2022, platform_id: win_amd64, architecture: x64}, + # {os: windows-2022, platform_id: win32, architecture: x86}, + # {os: macos-13, platform_id: macosx_x86_64, architecture: x86_64}, + # {os: macos-14, platform_id: macosx_arm64, architecture: arm64} + # ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Install Python with: python-version: ${{ matrix.python-version }} @@ -162,7 +158,7 @@ jobs: if: github.event_name== 'release' steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 diff --git a/.gitignore b/.gitignore index 3a8228e8..e165e89a 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,4 @@ cython_debug/ #temp folder .pytest_temp +.venv* diff --git a/packing/download_dlls.py b/packing/download_dlls.py index 733e6db0..c31c0450 100644 --- a/packing/download_dlls.py +++ b/packing/download_dlls.py @@ -10,7 +10,7 @@ from pathlib import Path from urllib.request import urlretrieve as download -PANGO_VERSION = "1.54.0-v1" +PANGO_VERSION = "1.54.0-v3" def get_platform(): @@ -28,7 +28,7 @@ def get_platform(): download_url = ( "https://github.com/naveen521kk/pango-build/releases" - f"/download/v{PANGO_VERSION}/pango-v{PANGO_VERSION}-{plat}.zip" + f"/download/v{PANGO_VERSION}/pango-v{PANGO_VERSION}-windows-{plat}.zip" ) final_location = Path(r"C:\cibw\vendor") download_location = Path(tempfile.mkdtemp()) @@ -61,7 +61,7 @@ def get_platform(): rex = re.compile("^prefix=(.*)") -def new_place(_: re.Match[str]) -> str: +def new_place(_) -> str: return f"prefix={str(final_location.as_posix())}" @@ -77,7 +77,7 @@ def new_place(_: re.Match[str]) -> str: logging.info("Getting pkg-config") download( url="https://github.com/naveen521kk/pango-build" - f"/releases/download/v{PANGO_VERSION}/pkgconf.zip", + f"/releases/download/v{PANGO_VERSION}/pkgconf-windows.zip", filename=download_file, ) with zipfile.ZipFile( diff --git a/packing/download_pango_macos.py b/packing/download_pango_macos.py new file mode 100644 index 00000000..773ad7e6 --- /dev/null +++ b/packing/download_pango_macos.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import logging +import os +import re +import shutil +import sys +import tempfile +import zipfile +from pathlib import Path +from urllib.request import urlretrieve as download + +PANGO_VERSION = "1.54.0-v3" + +logging.basicConfig(format="%(levelname)s - %(message)s", level=logging.DEBUG) + + +plat = sys.argv[1] +logging.debug(f"Platform is {plat}") + +download_url = ( + "https://github.com/naveen521kk/pango-build/releases" + f"/download/v{PANGO_VERSION}/pango-v{PANGO_VERSION}-mac-{plat}.zip" +) +final_location = Path(r"~/pangobuild").expanduser() +download_location = Path(tempfile.mkdtemp()) +if final_location.exists(): + logging.info("Final Location already exists clearing it...") + shutil.rmtree(str(final_location)) +os.makedirs(final_location) +download_file = download_location / "build.zip" +logging.info("Downloading Pango and Cairo Binaries for macOS...") +logging.info("Url: %s", download_url) +download(url=download_url, filename=download_file) +logging.info(f"Download complete. Saved to {download_file}.") +logging.info(f"Extracting {download_file} to {download_location}...") +with zipfile.ZipFile( + download_file, mode="r", compression=zipfile.ZIP_DEFLATED +) as file: # noqa: E501 + file.extractall(download_location) +os.remove(download_file) +logging.info("Completed Extracting.") +logging.info("Moving Files accordingly.") + +plat_location = download_location / f"mac-pango-{plat}" +for src_file in plat_location.glob("*"): + logging.debug(f"Moving {src_file} to {final_location}...") + shutil.move(str(src_file), str(final_location)) +logging.info("Moving files Completed") +logging.info("Fixing .pc files") + + +rex = re.compile("^prefix=(.*)") + + +def new_place(_) -> str: + return f"prefix={str(final_location.as_posix())}" + + +pc_files = final_location / "lib" / "pkgconfig" +for i in pc_files.glob("*.pc"): + logging.info(f"Writing {i}") + with open(i) as f: + content = f.read() + final = rex.sub(new_place, content) + with open(i, "w") as f: + f.write(final)