Skip to content

Commit 550f472

Browse files
committed
CI: fix tests on windows
1 parent 9aa0534 commit 550f472

File tree

4 files changed

+30
-46
lines changed

4 files changed

+30
-46
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ jobs:
8080
python-version: ${{ matrix.python-version }}
8181
architecture: ${{matrix.architecture}}
8282
allow-prereleases: true
83-
- name: Cache Windows
84-
id: cache-windows
85-
uses: actions/cache@v3
86-
with:
87-
path: C:\cibw\pkg-config
88-
key: ${{ hashFiles('packing/download_dlls.py') }}-${{ hashFiles('packing/build_pkgconfig.ps1') }}
8983
- name: Download Binary
9084
run: |
9185
python packing/download_dlls.py

packing/build_pkgconfig.ps1

Lines changed: 0 additions & 28 deletions
This file was deleted.

packing/download_dlls.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
import logging
44
import os
55
import re
6-
import shlex
76
import shutil
87
import struct
9-
import subprocess
108
import tempfile
119
import zipfile
1210
from pathlib import Path
1311
from urllib.request import urlretrieve as download
1412

15-
PANGO_VERSION = "1.54.0"
13+
PANGO_VERSION = "1.54.0-v1"
1614

1715

1816
def get_platform():
@@ -63,7 +61,7 @@ def get_platform():
6361
rex = re.compile("^prefix=(.*)")
6462

6563

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

6967

@@ -76,12 +74,31 @@ def new_place(some):
7674
with open(i, "w") as f:
7775
f.write(final)
7876

79-
logging.info("Building pkg-config")
77+
logging.info("Getting pkg-config")
78+
download(
79+
url="https://github.com/naveen521kk/pango-build"
80+
f"/releases/download/v{PANGO_VERSION}/pkgconf.zip",
81+
filename=download_file,
82+
)
83+
with zipfile.ZipFile(
84+
download_file, mode="r", compression=zipfile.ZIP_DEFLATED
85+
) as file: # noqa: E501
86+
file.extractall(download_location)
8087

81-
pkg_config_log = r"C:\cibw\pkg-config"
82-
build_file_loc = str(
83-
(Path(__file__).parent.resolve() / "build_pkgconfig.ps1").absolute()
88+
os.makedirs(str(final_location / "bin"), exist_ok=True)
89+
shutil.move(
90+
str(download_location / "pkgconf" / "bin" / "pkgconf.exe"),
91+
str(final_location / "bin"),
92+
)
93+
# alias pkgconf to pkg-config
94+
shutil.copy(
95+
final_location / "bin" / "pkgconf.exe", final_location / "bin" / "pkg-config.exe"
8496
)
85-
command = f'powershell -nologo -noexit -file "{build_file_loc}" "{pkg_config_log}"'
86-
print(command)
87-
subprocess.check_call(shlex.split(command), shell=True)
97+
98+
# On MSVC, meson would create static libraries as
99+
# libcairo.a but setuptools doens't know about it.
100+
libreg = re.compile(r"lib(?P<name>\S*)\.a")
101+
libdir = final_location / "lib"
102+
for lib in libdir.glob("lib*.a"):
103+
name = libreg.match(lib.name).group("name") + ".lib"
104+
shutil.move(lib, libdir / name)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,12 @@ def update_dict(dict1: dict, dict2: dict):
212212
_pkg_config_pangowin32 = PKG_CONFIG("pangowin32")
213213
returns = update_dict(returns, _pkg_config_pangowin32.setuptools_args)
214214

215-
returns["libraries"] += ["Gdi32"]
215+
returns["libraries"] += ["Gdi32", "User32", "Advapi32", "Shell32", "Ole32"]
216216
if not sysconfig.get_platform().startswith("mingw"): # MSVC compilers
217217
returns["libraries"] = list(
218218
set(returns["libraries"]).difference(IGNORE_LIBS_WIN)
219219
)
220+
returns["extra_compile_args"] = ["-DCAIRO_WIN32_STATIC_BUILD"]
220221
if hasattr(returns, "define_macros"):
221222
returns["define_macros"] += [("UNICODE", 1)]
222223
else:

0 commit comments

Comments
 (0)