Skip to content

Commit

Permalink
Fix install on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed May 28, 2024
1 parent da5b330 commit 2822bca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
build-wheels:
name: Build ${{ matrix.only }}
name: build ${{ matrix.only }}
needs: build-wheels-matrix
runs-on: ${{ matrix.os }}

Expand Down
27 changes: 15 additions & 12 deletions add_libmagic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ install_source() {
# install from source
# https://www.darwinsys.com/file/
# https://github.com/file/file/blob/FILE5_45/INSTALL#L51
version="file-5.45" &&
tmpfile="$(mktemp)" &&
curl -sSLo "${tmpfile}" "https://astron.com/pub/file/${version}.tar.gz" &&
tar xvf "${tmpfile}" &&
cd "${version}" &&
./configure &&
make &&
make install &&
make installcheck &&
cd .. &&
rm -r "${version}"
(
version="file-5.45" &&
tmpfile="$(mktemp)" &&
curl -sSLo "${tmpfile}" "https://astron.com/pub/file/${version}.tar.gz" &&
tar xvf "${tmpfile}" &&
cd "${version}" &&
./configure &&
make &&
make install &&
make installcheck &&
cd .. &&
rm -r "${version}"
) || ( cd .. && false )
}

install_precompiled() {
Expand All @@ -37,6 +39,7 @@ install_precompiled() {
else
# windows (no install, just download into current working directory)
# could also consider install using `pacman`: https://packages.msys2.org/base/mingw-w64-file
# which would require an update of copy_libmagic below to account for new magic.mgc paths
python <<EOF
import platform, sysconfig, io, zipfile, urllib.request
assert platform.system() == "Windows"
Expand All @@ -56,7 +59,7 @@ copy_libmagic() {
# this python command relies on current working directory containing `./magic/loader.py`
libmagic_path="$(python -c 'from magic.loader import load_lib; print(load_lib()._name)')" &&
cp "${libmagic_path}" "magic" &&
# only on linux: additionally copy compiled db into magic dir (prefer the one installed by install_source)
# only on linux/macos: additionally copy compiled db into magic dir (prefer the one installed by install_source)
( ( cp "/usr/local/share/misc/magic.mgc" "magic" || cp "/usr/share/misc/magic.mgc" "magic" ) || true ) &&
# check what was copied
ls -ltra magic
Expand Down

0 comments on commit 2822bca

Please sign in to comment.