Skip to content

Commit

Permalink
CI: fix tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
naveen521kk committed Sep 13, 2024
1 parent 9aa0534 commit 550f472
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 46 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ jobs:
python-version: ${{ matrix.python-version }}
architecture: ${{matrix.architecture}}
allow-prereleases: true
- name: Cache Windows
id: cache-windows
uses: actions/cache@v3
with:
path: C:\cibw\pkg-config
key: ${{ hashFiles('packing/download_dlls.py') }}-${{ hashFiles('packing/build_pkgconfig.ps1') }}
- name: Download Binary
run: |
python packing/download_dlls.py
Expand Down
28 changes: 0 additions & 28 deletions packing/build_pkgconfig.ps1

This file was deleted.

39 changes: 28 additions & 11 deletions packing/download_dlls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
import logging
import os
import re
import shlex
import shutil
import struct
import subprocess
import tempfile
import zipfile
from pathlib import Path
from urllib.request import urlretrieve as download

PANGO_VERSION = "1.54.0"
PANGO_VERSION = "1.54.0-v1"


def get_platform():
Expand Down Expand Up @@ -63,7 +61,7 @@ def get_platform():
rex = re.compile("^prefix=(.*)")


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


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

logging.info("Building pkg-config")
logging.info("Getting pkg-config")
download(
url="https://github.com/naveen521kk/pango-build"
f"/releases/download/v{PANGO_VERSION}/pkgconf.zip",
filename=download_file,
)
with zipfile.ZipFile(
download_file, mode="r", compression=zipfile.ZIP_DEFLATED
) as file: # noqa: E501
file.extractall(download_location)

pkg_config_log = r"C:\cibw\pkg-config"
build_file_loc = str(
(Path(__file__).parent.resolve() / "build_pkgconfig.ps1").absolute()
os.makedirs(str(final_location / "bin"), exist_ok=True)
shutil.move(
str(download_location / "pkgconf" / "bin" / "pkgconf.exe"),
str(final_location / "bin"),
)
# alias pkgconf to pkg-config
shutil.copy(
final_location / "bin" / "pkgconf.exe", final_location / "bin" / "pkg-config.exe"
)
command = f'powershell -nologo -noexit -file "{build_file_loc}" "{pkg_config_log}"'
print(command)
subprocess.check_call(shlex.split(command), shell=True)

# On MSVC, meson would create static libraries as
# libcairo.a but setuptools doens't know about it.
libreg = re.compile(r"lib(?P<name>\S*)\.a")
libdir = final_location / "lib"
for lib in libdir.glob("lib*.a"):
name = libreg.match(lib.name).group("name") + ".lib"
shutil.move(lib, libdir / name)
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,12 @@ def update_dict(dict1: dict, dict2: dict):
_pkg_config_pangowin32 = PKG_CONFIG("pangowin32")
returns = update_dict(returns, _pkg_config_pangowin32.setuptools_args)

returns["libraries"] += ["Gdi32"]
returns["libraries"] += ["Gdi32", "User32", "Advapi32", "Shell32", "Ole32"]
if not sysconfig.get_platform().startswith("mingw"): # MSVC compilers
returns["libraries"] = list(
set(returns["libraries"]).difference(IGNORE_LIBS_WIN)
)
returns["extra_compile_args"] = ["-DCAIRO_WIN32_STATIC_BUILD"]
if hasattr(returns, "define_macros"):
returns["define_macros"] += [("UNICODE", 1)]
else:
Expand Down

0 comments on commit 550f472

Please sign in to comment.