Skip to content

Commit

Permalink
CI: fix wheels build
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
naveen521kk committed Sep 13, 2024
1 parent 170c7dd commit 895dfea
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 52 deletions.
92 changes: 44 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
env:
PKG_CONFIG_PATH: "C:\\cibw\\vendor\\lib\\pkgconfig"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ cython_debug/

#temp folder
.pytest_temp
.venv*
8 changes: 4 additions & 4 deletions packing/download_dlls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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())
Expand Down Expand Up @@ -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())}"


Expand All @@ -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(
Expand Down
67 changes: 67 additions & 0 deletions packing/download_pango_macos.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 895dfea

Please sign in to comment.