Skip to content

Commit ace058d

Browse files
authored
Merge pull request #113 from ManimCommunity/fix-wheel-build
CI: fix wheels build
2 parents 170c7dd + 826342a commit ace058d

File tree

4 files changed

+151
-61
lines changed

4 files changed

+151
-61
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,100 +16,122 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os: [macos-11, windows-2019]
20-
bitness: [32, 64]
2119
include:
2220
# Run 32 and 64 bit version in parallel for Windows
23-
- os: windows-2019
24-
bitness: 64
21+
- os: windows-2022
2522
platform_id: win_amd64
26-
- os: windows-2019
27-
bitness: 32
23+
architecture: x64
24+
- os: windows-2022
2825
platform_id: win32
29-
- os: macos-11
30-
bitness: 64
26+
architecture: x86
27+
- os: macos-13
3128
platform_id: macosx_x86_64
32-
exclude:
33-
- os: macos-11
34-
bitness: 32
29+
architecture: x64
30+
- os: macos-14
31+
platform_id: macosx_arm64
32+
architecture: arm64
3533
env:
36-
CIBW_BUILD: cp38-${{ matrix.platform_id }} cp39-${{ matrix.platform_id }} cp310-${{ matrix.platform_id }} cp311-${{ matrix.platform_id }} cp312-${{ matrix.platform_id }}
37-
CIBW_SKIP: pp* cp35* cp36* cp37*
38-
CIBW_BEFORE_BUILD_MACOS: "source packing/build_pango_mac.sh"
34+
CIBW_BUILD: cp39-${{ matrix.platform_id }} cp310-${{ matrix.platform_id }} cp311-${{ matrix.platform_id }} cp312-${{ matrix.platform_id }} cp313-${{ matrix.platform_id }}
35+
CIBW_SKIP: pp* cp36* cp37* cp38*
36+
CIBW_BEFORE_BUILD_MACOS: "python packing/download_pango_macos.py ${{ matrix.architecture }}"
3937
CIBW_BEFORE_BUILD_WINDOWS: "python packing/download_dlls.py"
4038
CIBW_ENVIRONMENT_WINDOWS: "PKG_CONFIG_PATH='C:\\cibw\\vendor\\lib\\pkgconfig'"
4139
CIBW_ENVIRONMENT_MACOS: "PKG_CONFIG_PATH='/Users/runner/pangobuild/lib/pkgconfig'"
42-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python packing/inject-dlls.py {wheel} {dest_dir} C:\cibw\vendor\bin
4340
CIBW_TEST_REQUIRES: pytest pytest-cov
4441
CIBW_TEST_COMMAND: "bash {project}/packing/test_wheels.sh {project}"
4542
steps:
46-
- uses: actions/checkout@v3
47-
- uses: actions/setup-python@v4
48-
name: Install Python
49-
with:
50-
python-version: "3.8"
51-
52-
- name: Install cibuildwheel
53-
env:
54-
event_name: ${{ github.event_name }}
55-
continue-on-error: true
56-
shell: bash
43+
- uses: actions/checkout@v4
44+
- name: Set Path for pkg-config
45+
if: runner.os == 'windows'
5746
run: |
58-
python -m pip install cibuildwheel==2.16.1
59-
echo "$event_name"
47+
$env:Path = "C:\cibw\pkg-config\bin;C:\cibw\vendor\bin;$($env:PATH)"
48+
echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
6049
6150
- name: Build wheels (Windows)
6251
if: runner.os == 'windows'
52+
shell: pwsh
6353
run: |
64-
$ErrorActionPreference = 'Stop'
65-
$env:PATH="$env:PATH;C:\cibw\pkg-config\bin"
66-
$env:PKG_CONFIG_PATH="C:\cibw\vendor\lib\pkgconfig"
6754
Copy-Item packing/LICENSE.bin .
6855
Rename-Item LICENSE.bin LICENSE.win32
69-
python -m cibuildwheel --output-dir wheelhouse
7056
7157
- name: Build wheels (Non-Windows)
7258
if: runner.os != 'windows'
7359
run: |
7460
cp packing/LICENSE.bin .
75-
python -m cibuildwheel --output-dir wheelhouse
61+
62+
- name: Build wheels
63+
uses: pypa/[email protected]
64+
env:
65+
PKG_CONFIG_PATH: "C:\\cibw\\vendor\\lib\\pkgconfig"
7666

7767
- uses: actions/upload-artifact@v3
7868
with:
7969
path: ./wheelhouse/*.whl
8070
name: wheels-${{ runner.os }}-${{ matrix.platform_id }}
8171

82-
test_wheels:
83-
name: Test wheels on ${{ matrix.os }}-${{ matrix.platform_id }}-${{ matrix.python-version }}
72+
test_wheels_win:
73+
name: Test wheels on Windows - ${{ matrix.platform_id }} (${{ matrix.python-version }})
8474
needs: [build_wheels]
85-
runs-on: ${{ matrix.os }}
75+
runs-on: windows-latest
8676
strategy:
8777
fail-fast: false
8878
matrix:
89-
os: [macos-11, windows-2019]
90-
architecture: [x86, x64]
91-
python-version: ['3.8', '3.9', '3.10', '3.11']
92-
include:
93-
- os: windows-2019
94-
architecture: x64
95-
platform_id: win_amd64
96-
- os: windows-2019
97-
architecture: x86
98-
platform_id: win32
99-
- os: macos-11
100-
architecture: x64
101-
platform_id: macosx_x86_64
102-
exclude:
103-
- os: macos-11
104-
architecture: x86
79+
architecture: [x64, x86]
80+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
81+
include: [
82+
{platform_id: win_amd64, architecture: x64},
83+
{platform_id: win32, architecture: x86},
84+
]
10585
steps:
106-
- uses: actions/checkout@v3
86+
- uses: actions/checkout@v4
10787

108-
- uses: actions/setup-python@v4
88+
- uses: actions/setup-python@v5
10989
name: Install Python
11090
with:
11191
python-version: ${{ matrix.python-version }}
11292
architecture: ${{ matrix.architecture }}
93+
allow-prereleases: true
94+
95+
- uses: actions/download-artifact@v3
96+
with:
97+
name: wheels-${{ runner.os }}-${{ matrix.platform_id }}
98+
path: ~/wheelhouse
99+
100+
- name: Install test dependencies
101+
run: |
102+
pip install pytest pytest-cov
103+
104+
- name: Install wheels
105+
run: |
106+
pip install --no-index --find-links ~/wheelhouse ManimPango
107+
108+
- name: Run tests
109+
shell: bash
110+
run: |
111+
bash packing/test_wheels.sh $(pwd)
112+
113+
test_wheels_mac:
114+
name: Test wheels on macOS - ${{ matrix.platform_id }} (${{ matrix.python-version }})
115+
needs: [build_wheels]
116+
runs-on: ${{ matrix.os }}
117+
strategy:
118+
fail-fast: false
119+
matrix:
120+
architecture: [x64, arm64]
121+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
122+
include: [
123+
{platform_id: macosx_x86_64, architecture: x64, os: macos-13},
124+
{platform_id: macosx_arm64, architecture: arm64, os: macos-14},
125+
]
126+
steps:
127+
- uses: actions/checkout@v4
128+
129+
- uses: actions/setup-python@v5
130+
name: Install Python
131+
with:
132+
python-version: ${{ matrix.python-version }}
133+
architecture: ${{ matrix.architecture == 'arm64' && null || matrix.architecture }}
134+
allow-prereleases: true
113135

114136
- uses: actions/download-artifact@v3
115137
with:
@@ -130,7 +152,7 @@ jobs:
130152
bash packing/test_wheels.sh $(pwd)
131153
132154
publish_wheels:
133-
needs: [test_wheels]
155+
needs: [test_wheels_mac, test_wheels_win]
134156
name: Upload wheels
135157
runs-on: ubuntu-latest
136158
if: github.event_name== 'release'
@@ -162,7 +184,7 @@ jobs:
162184
if: github.event_name== 'release'
163185
steps:
164186
- name: Checkout
165-
uses: actions/checkout@v3
187+
uses: actions/checkout@v4
166188

167189
- name: Setup Python
168190
uses: actions/setup-python@v4
@@ -221,7 +243,7 @@ jobs:
221243
asset_content_type: application/gzip
222244

223245
success:
224-
needs: [test_wheels]
246+
needs: [test_wheels_win, test_wheels_mac]
225247
runs-on: ubuntu-latest
226248
name: Building and testing of wheels success
227249
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,4 @@ cython_debug/
147147

148148
#temp folder
149149
.pytest_temp
150+
.venv*

packing/download_dlls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pathlib import Path
1111
from urllib.request import urlretrieve as download
1212

13-
PANGO_VERSION = "1.54.0-v1"
13+
PANGO_VERSION = "1.54.0-v3"
1414

1515

1616
def get_platform():
@@ -28,7 +28,7 @@ def get_platform():
2828

2929
download_url = (
3030
"https://github.com/naveen521kk/pango-build/releases"
31-
f"/download/v{PANGO_VERSION}/pango-v{PANGO_VERSION}-{plat}.zip"
31+
f"/download/v{PANGO_VERSION}/pango-v{PANGO_VERSION}-windows-{plat}.zip"
3232
)
3333
final_location = Path(r"C:\cibw\vendor")
3434
download_location = Path(tempfile.mkdtemp())
@@ -61,7 +61,7 @@ def get_platform():
6161
rex = re.compile("^prefix=(.*)")
6262

6363

64-
def new_place(_: re.Match[str]) -> str:
64+
def new_place(_) -> str:
6565
return f"prefix={str(final_location.as_posix())}"
6666

6767

@@ -77,7 +77,7 @@ def new_place(_: re.Match[str]) -> str:
7777
logging.info("Getting pkg-config")
7878
download(
7979
url="https://github.com/naveen521kk/pango-build"
80-
f"/releases/download/v{PANGO_VERSION}/pkgconf.zip",
80+
f"/releases/download/v{PANGO_VERSION}/pkgconf-windows.zip",
8181
filename=download_file,
8282
)
8383
with zipfile.ZipFile(

packing/download_pango_macos.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import logging
4+
import os
5+
import re
6+
import shutil
7+
import sys
8+
import tempfile
9+
import zipfile
10+
from pathlib import Path
11+
from urllib.request import urlretrieve as download
12+
13+
PANGO_VERSION = "1.54.0-v3"
14+
15+
logging.basicConfig(format="%(levelname)s - %(message)s", level=logging.DEBUG)
16+
17+
18+
plat = sys.argv[1]
19+
logging.debug(f"Platform is {plat}")
20+
21+
download_url = (
22+
"https://github.com/naveen521kk/pango-build/releases"
23+
f"/download/v{PANGO_VERSION}/pango-v{PANGO_VERSION}-mac-{plat}.zip"
24+
)
25+
final_location = Path(r"~/pangobuild").expanduser()
26+
download_location = Path(tempfile.mkdtemp())
27+
if final_location.exists():
28+
logging.info("Final Location already exists clearing it...")
29+
shutil.rmtree(str(final_location))
30+
os.makedirs(final_location)
31+
download_file = download_location / "build.zip"
32+
logging.info("Downloading Pango and Cairo Binaries for macOS...")
33+
logging.info("Url: %s", download_url)
34+
download(url=download_url, filename=download_file)
35+
logging.info(f"Download complete. Saved to {download_file}.")
36+
logging.info(f"Extracting {download_file} to {download_location}...")
37+
with zipfile.ZipFile(
38+
download_file, mode="r", compression=zipfile.ZIP_DEFLATED
39+
) as file: # noqa: E501
40+
file.extractall(download_location)
41+
os.remove(download_file)
42+
logging.info("Completed Extracting.")
43+
logging.info("Moving Files accordingly.")
44+
45+
plat_location = download_location / f"mac-pango-{plat}"
46+
for src_file in plat_location.glob("*"):
47+
logging.debug(f"Moving {src_file} to {final_location}...")
48+
shutil.move(str(src_file), str(final_location))
49+
logging.info("Moving files Completed")
50+
logging.info("Fixing .pc files")
51+
52+
53+
rex = re.compile("^prefix=(.*)")
54+
55+
56+
def new_place(_) -> str:
57+
return f"prefix={str(final_location.as_posix())}"
58+
59+
60+
pc_files = final_location / "lib" / "pkgconfig"
61+
for i in pc_files.glob("*.pc"):
62+
logging.info(f"Writing {i}")
63+
with open(i) as f:
64+
content = f.read()
65+
final = rex.sub(new_place, content)
66+
with open(i, "w") as f:
67+
f.write(final)

0 commit comments

Comments
 (0)