33import logging
44import os
55import re
6- import shlex
76import shutil
87import struct
9- import subprocess
108import tempfile
119import zipfile
1210from pathlib import Path
1311from urllib .request import urlretrieve as download
1412
15- PANGO_VERSION = "1.54.0"
13+ PANGO_VERSION = "1.54.0-v1 "
1614
1715
1816def get_platform ():
@@ -63,7 +61,7 @@ def get_platform():
6361rex = 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 )
0 commit comments