Skip to content

Commit 3abe23e

Browse files
committed
1 parent 1b885cc commit 3abe23e

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

.github/workflows/wheels.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ jobs:
9292
with:
9393
msystem: MINGW64
9494
update: true
95-
install: >-
96-
${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-libgnurx' || 'mingw-w64-x86_64-libgnurx' }}
9795

9896
- uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above
9997
timeout-minutes: 10

add_libmagic.sh

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ install_precompiled() {
2626
# Debian https://packages.ubuntu.com/libmagic1
2727
# Alpine https://pkgs.alpinelinux.org/package/libmagic
2828
# RHEL https://git.almalinux.org/rpms/file
29-
# Windows https://github.com/julian-r/file-windows
29+
# Windows https://packages.msys2.org/base/mingw-w64-file
3030
if [ -n "$(which brew)" ]; then
3131
brew install libmagic
3232
elif [ -n "$(which apt-get)" ]; then
@@ -36,20 +36,8 @@ install_precompiled() {
3636
apk add --update libmagic
3737
elif [ -n "$(which dnf)" ]; then
3838
dnf --setopt install_weak_deps=false -y install file-libs
39-
else
40-
# windows (no install, just download into current working directory)
41-
# could also consider install using `pacman`: https://packages.msys2.org/base/mingw-w64-file
42-
# which would require an update of copy_libmagic below to account for new magic.mgc paths
43-
python <<EOF
44-
import platform, sysconfig, io, zipfile, urllib.request
45-
assert platform.system() == "Windows"
46-
machine = "x86" if sysconfig.get_platform() == "win32" else "x64"
47-
url = f"https://github.com/julian-r/file-windows/releases/download/v5.44/file_5.44-build104-vs2022-{machine}.zip"
48-
print("Downloading", url)
49-
zipfile.ZipFile(io.BytesIO(urllib.request.urlopen(url).read())).extractall(".")
50-
EOF
51-
# check what was copied
52-
ls -ltra
39+
elif [ -n "$(which pacman)" ]; then
40+
pacman -S "mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-file"
5341
fi
5442
}
5543

@@ -59,8 +47,8 @@ copy_libmagic() {
5947
# this python command relies on current working directory containing `./magic/loader.py`
6048
libmagic_path="$(python -c 'from magic.loader import load_lib; print(load_lib()._name)')" &&
6149
cp "${libmagic_path}" "magic" &&
62-
# only on linux/macos: additionally copy compiled db into magic dir (prefer the one installed by install_source)
63-
( ( cp "/usr/local/share/misc/magic.mgc" "magic" || cp "/usr/share/misc/magic.mgc" "magic" ) || true ) &&
50+
# additionally copy compiled db into magic dir (prefer the one installed by install_source)
51+
( ( ( cp "/usr/local/share/misc/magic.mgc" "magic" || cp "/usr/share/misc/magic.mgc" "magic" ) || cp "/mingw64/share/misc/magic.mgc" "magic" ) || true ) &&
6452
# check what was copied
6553
ls -ltra magic
6654
}

0 commit comments

Comments
 (0)