From bf01ad72ed31eaf25ad81d3527ce22605ab8727c Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:37:42 +0200 Subject: [PATCH 01/34] Fix install_source for Windows --- add_libmagic.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/add_libmagic.sh b/add_libmagic.sh index 4d6fd8a..57a81ce 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -3,8 +3,10 @@ set -euxo pipefail install_source() { - # skip on Windows for now - python -c 'import platform; assert platform.system() != "Windows"' || exit 1 + if [ -n "$(which pacman)" ]; then + # install regex headers on windows + pacman -S "mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-libgnurx" + fi # install from source # https://www.darwinsys.com/file/ # https://github.com/file/file/blob/FILE5_46/INSTALL#L51 From 1b885cc51a985fc5d9a90a3495c34c032d797766 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:57:21 +0200 Subject: [PATCH 02/34] Attempt build from source on windows --- .github/workflows/wheels.yml | 9 +++++++++ add_libmagic.sh | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 77fa59c..79aecb7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -86,6 +86,15 @@ jobs: if: runner.os == 'Linux' uses: docker/setup-qemu-action@v3 + - name: Setup MSYS2 and install regex + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: >- + ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-libgnurx' || 'mingw-w64-x86_64-libgnurx' }} + - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 with: diff --git a/add_libmagic.sh b/add_libmagic.sh index 57a81ce..ad52017 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -3,10 +3,6 @@ set -euxo pipefail install_source() { - if [ -n "$(which pacman)" ]; then - # install regex headers on windows - pacman -S "mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-libgnurx" - fi # install from source # https://www.darwinsys.com/file/ # https://github.com/file/file/blob/FILE5_46/INSTALL#L51 From 3abe23e925e5c0da5b7589ffac27791aa4c60973 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Sat, 15 Mar 2025 21:06:09 +0200 Subject: [PATCH 03/34] Deprecate https://github.com/julian-r/file-windows --- .github/workflows/wheels.yml | 2 -- add_libmagic.sh | 22 +++++----------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 79aecb7..24de922 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -92,8 +92,6 @@ jobs: with: msystem: MINGW64 update: true - install: >- - ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-libgnurx' || 'mingw-w64-x86_64-libgnurx' }} - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 diff --git a/add_libmagic.sh b/add_libmagic.sh index ad52017..60a0afc 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -26,7 +26,7 @@ install_precompiled() { # Debian https://packages.ubuntu.com/libmagic1 # Alpine https://pkgs.alpinelinux.org/package/libmagic # RHEL https://git.almalinux.org/rpms/file - # Windows https://github.com/julian-r/file-windows + # Windows https://packages.msys2.org/base/mingw-w64-file if [ -n "$(which brew)" ]; then brew install libmagic elif [ -n "$(which apt-get)" ]; then @@ -36,20 +36,8 @@ install_precompiled() { apk add --update libmagic elif [ -n "$(which dnf)" ]; then dnf --setopt install_weak_deps=false -y install file-libs - 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 < Date: Sun, 16 Mar 2025 18:19:43 +0200 Subject: [PATCH 04/34] Try msys2 --- add_libmagic.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/add_libmagic.sh b/add_libmagic.sh index 60a0afc..2eead00 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -36,8 +36,9 @@ install_precompiled() { apk add --update libmagic elif [ -n "$(which dnf)" ]; then dnf --setopt install_weak_deps=false -y install file-libs - elif [ -n "$(which pacman)" ]; then - pacman -S "mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-file" + elif [ -n "$(which msys2)" ]; then + pkg="mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-file" + msys2 -c "pacman -Sy ${pkg}" fi } From 0b49a23768326a44e9485d4b36160621d2f7397f Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Mon, 17 Mar 2025 08:06:19 +0200 Subject: [PATCH 05/34] Use msys2dl --- add_libmagic.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/add_libmagic.sh b/add_libmagic.sh index 2eead00..6df4164 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -36,9 +36,12 @@ install_precompiled() { apk add --update libmagic elif [ -n "$(which dnf)" ]; then dnf --setopt install_weak_deps=false -y install file-libs - elif [ -n "$(which msys2)" ]; then + elif python -c 'import platform; assert platform.system() == "Windows"'; then pkg="mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-file" - msys2 -c "pacman -Sy ${pkg}" + pip install msys2dl + msys2dl extract --output / ${pkg} + # this is a libmagic dependency which also needs to be packaged + cp "/mingw64/bin/libsystre-0.dll" "magic" fi } From 97feee06bcdea8a922deeee03d56ed6e16ef3ef5 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:04:18 +0200 Subject: [PATCH 06/34] Use ddl from msys2 --- .github/workflows/wheels.yml | 11 ++++++++++- add_libmagic.sh | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 24de922..1044957 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -86,12 +86,21 @@ jobs: if: runner.os == 'Linux' uses: docker/setup-qemu-action@v3 - - name: Setup MSYS2 and install regex + - name: Setup MSYS2 and install file if: runner.os == 'Windows' uses: msys2/setup-msys2@v2 with: msystem: MINGW64 update: true + install: >- + ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-file' || 'mingw-w64-x86_64-file' }} + + - name: Copy Windows ddl and mgc + if: runner.os == 'Windows' + run: + cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" + cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" + cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 diff --git a/add_libmagic.sh b/add_libmagic.sh index 6df4164..41d5c58 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -57,6 +57,8 @@ copy_libmagic() { ls -ltra magic } +# skip windows (taken care of separately in wheels.yml) +python -c 'import platform; assert platform.system() != "Windows"' || exit 0 # prefer a recent build from source install_source || install_precompiled # files to be copied into the wheel From 0d640541078641a193d444ea7ddbd46b284d5548 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:57:17 +0200 Subject: [PATCH 07/34] Typo --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1044957..aa85ae6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -97,7 +97,7 @@ jobs: - name: Copy Windows ddl and mgc if: runner.os == 'Windows' - run: + run: | cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" From bf12a034ee03a7cd535f0996b21b8694af6d9572 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:02:43 +0200 Subject: [PATCH 08/34] Fix location --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index aa85ae6..ce9e129 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -92,6 +92,7 @@ jobs: with: msystem: MINGW64 update: true + location: D:\ install: >- ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-file' || 'mingw-w64-x86_64-file' }} From 7a2153cdddb5d286ea52d730aaa247a4d103b206 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:07:40 +0200 Subject: [PATCH 09/34] Test --- .github/workflows/wheels.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ce9e129..97a5711 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -99,6 +99,8 @@ jobs: - name: Copy Windows ddl and mgc if: runner.os == 'Windows' run: | + ls / + ls /msys2 cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" From 6428d819013a0759c94f90ec3492f319f2725627 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:09:22 +0200 Subject: [PATCH 10/34] Test --- .github/workflows/wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 97a5711..42d0a97 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -99,8 +99,7 @@ jobs: - name: Copy Windows ddl and mgc if: runner.os == 'Windows' run: | - ls / - ls /msys2 + ls /msys64 cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" From 987bf02d7d9557a82759be8a5e9a625b1a3f236a Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:10:28 +0200 Subject: [PATCH 11/34] Add concurrency --- .github/workflows/ci.yml | 3 +++ .github/workflows/wheels.yml | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f284e8c..872a424 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: ci on: [push, pull_request] +concurrency: # https://stackoverflow.com/questions/66335225#comment133398800_72408109 + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: ci: strategy: diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 42d0a97..48d0346 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -8,8 +8,11 @@ on: types: [released, prereleased] workflow_dispatch: # allows running workflow manually from the Actions tab -jobs: +concurrency: # https://stackoverflow.com/questions/66335225#comment133398800_72408109 + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} +jobs: build-sdist: runs-on: ubuntu-latest From 4e0102e90e73ae29068bb45572e10b3d7abc0d9a Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:12:53 +0200 Subject: [PATCH 12/34] Fix --- .github/workflows/wheels.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 48d0346..893e904 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -93,7 +93,7 @@ jobs: if: runner.os == 'Windows' uses: msys2/setup-msys2@v2 with: - msystem: MINGW64 + msystem: ${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }} update: true location: D:\ install: >- @@ -102,10 +102,9 @@ jobs: - name: Copy Windows ddl and mgc if: runner.os == 'Windows' run: | - ls /msys64 - cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" - cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" - cp "/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From 035fb72529452cff4513a8c0c6a4f3075b159cca Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:19:46 +0200 Subject: [PATCH 13/34] Add pyproject.toml --- add_libmagic.sh | 2 +- pyproject.toml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/add_libmagic.sh b/add_libmagic.sh index 41d5c58..5feb02e 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -58,7 +58,7 @@ copy_libmagic() { } # skip windows (taken care of separately in wheels.yml) -python -c 'import platform; assert platform.system() != "Windows"' || exit 0 +python -c 'import platform; assert platform.system() != "Windows"' || ( echo "skipping on windows" && exit 0 ) # prefer a recent build from source install_source || install_precompiled # files to be copied into the wheel diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fed528d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" From 4ee37ec90d9e6a033efc10d9c326496ebf7cb4bd Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:23:14 +0200 Subject: [PATCH 14/34] Move to separate CIBW_BEFORE_BUILD --- .github/workflows/wheels.yml | 4 +++- pyproject.toml | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 pyproject.toml diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 893e904..b53b7ab 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -113,7 +113,9 @@ jobs: env: CIBW_BUILD_VERBOSITY: 1 # add compiled libmagic to the build directory (to include in the wheel) - CIBW_BEFORE_BUILD: ${{ ( startsWith( matrix.os, 'macos' ) && 'sudo -E bash add_libmagic.sh' ) || 'bash add_libmagic.sh' }} + CIBW_BEFORE_BUILD_MACOS: sudo -E bash add_libmagic.sh + CIBW_BEFORE_BUILD_LINUX: bash add_libmagic.sh + CIBW_BEFORE_BUILD_WINDOWS: pip install setuptools # build macos wheels with maximum backwards compatibility (gcc -mmacosx-version-min flag) MACOSX_DEPLOYMENT_TARGET: ${{ ( endsWith( matrix.only, 'arm64' ) && '11.0' ) || '10.9' }} # simple smoke test run on each wheel: this is an HLS MP4 video, only recognised in recent versions of libmagic diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index fed528d..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" From 5e0cd2077754bc7b1ead13f3b373097b3d83b830 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:27:10 +0200 Subject: [PATCH 15/34] Add -U --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b53b7ab..b567e78 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -115,7 +115,7 @@ jobs: # add compiled libmagic to the build directory (to include in the wheel) CIBW_BEFORE_BUILD_MACOS: sudo -E bash add_libmagic.sh CIBW_BEFORE_BUILD_LINUX: bash add_libmagic.sh - CIBW_BEFORE_BUILD_WINDOWS: pip install setuptools + CIBW_BEFORE_BUILD_WINDOWS: pip install -U setuptools # build macos wheels with maximum backwards compatibility (gcc -mmacosx-version-min flag) MACOSX_DEPLOYMENT_TARGET: ${{ ( endsWith( matrix.only, 'arm64' ) && '11.0' ) || '10.9' }} # simple smoke test run on each wheel: this is an HLS MP4 video, only recognised in recent versions of libmagic From 91fb055570c21ab9795e2dc4e583f6743f597746 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:28:52 +0200 Subject: [PATCH 16/34] Remove magic import from setup.py --- .github/workflows/wheels.yml | 1 - setup.py | 5 ----- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b567e78..c195d7e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -115,7 +115,6 @@ jobs: # add compiled libmagic to the build directory (to include in the wheel) CIBW_BEFORE_BUILD_MACOS: sudo -E bash add_libmagic.sh CIBW_BEFORE_BUILD_LINUX: bash add_libmagic.sh - CIBW_BEFORE_BUILD_WINDOWS: pip install -U setuptools # build macos wheels with maximum backwards compatibility (gcc -mmacosx-version-min flag) MACOSX_DEPLOYMENT_TARGET: ${{ ( endsWith( matrix.only, 'arm64' ) && '11.0' ) || '10.9' }} # simple smoke test run on each wheel: this is an HLS MP4 video, only recognised in recent versions of libmagic diff --git a/setup.py b/setup.py index 72e8d60..8220e25 100644 --- a/setup.py +++ b/setup.py @@ -6,11 +6,6 @@ import os import sys -# python packages should not install succesfully if libraries are missing -from magic.loader import load_lib - -load_lib()._name - def read(file_name): """Read a text file and return the content as a string.""" From e9787b3a0418ffb6aa433ec6634e48c250cd5446 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:35:25 +0200 Subject: [PATCH 17/34] Add more dlls --- .github/workflows/wheels.yml | 12 +++++++++++- add_libmagic.sh | 9 +-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c195d7e..9096df6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -91,7 +91,7 @@ jobs: - name: Setup MSYS2 and install file if: runner.os == 'Windows' - uses: msys2/setup-msys2@v2 + uses: msys2/setup-msys2@v2.27.0 with: msystem: ${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }} update: true @@ -105,6 +105,16 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/share/misc/magic.mgc" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libmagic-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libsystre-0.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libtre-5.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libasprintf-0.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libintl-8.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libatomic-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgcc_s_seh-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgomp-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libquadmath-0.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 diff --git a/add_libmagic.sh b/add_libmagic.sh index 5feb02e..b1133ff 100755 --- a/add_libmagic.sh +++ b/add_libmagic.sh @@ -26,7 +26,6 @@ install_precompiled() { # Debian https://packages.ubuntu.com/libmagic1 # Alpine https://pkgs.alpinelinux.org/package/libmagic # RHEL https://git.almalinux.org/rpms/file - # Windows https://packages.msys2.org/base/mingw-w64-file if [ -n "$(which brew)" ]; then brew install libmagic elif [ -n "$(which apt-get)" ]; then @@ -36,12 +35,6 @@ install_precompiled() { apk add --update libmagic elif [ -n "$(which dnf)" ]; then dnf --setopt install_weak_deps=false -y install file-libs - elif python -c 'import platform; assert platform.system() == "Windows"'; then - pkg="mingw-w64-$(python -c 'import sysconfig; print("i686" if sysconfig.get_platform() == "win32" else "x86_64")')-file" - pip install msys2dl - msys2dl extract --output / ${pkg} - # this is a libmagic dependency which also needs to be packaged - cp "/mingw64/bin/libsystre-0.dll" "magic" fi } @@ -52,7 +45,7 @@ copy_libmagic() { libmagic_path="$(python -c 'from magic.loader import load_lib; print(load_lib()._name)')" && cp "${libmagic_path}" "magic" && # 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" ) || cp "/mingw64/share/misc/magic.mgc" "magic" ) || true ) && + ( ( cp "/usr/local/share/misc/magic.mgc" "magic" || cp "/usr/share/misc/magic.mgc" "magic" ) || true ) && # check what was copied ls -ltra magic } From 08ce7308e59bd9f8dce6d0976495996ac4463647 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:38:07 +0200 Subject: [PATCH 18/34] Simplify --- .github/workflows/wheels.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9096df6..dc14a9f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -94,8 +94,6 @@ jobs: uses: msys2/setup-msys2@v2.27.0 with: msystem: ${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }} - update: true - location: D:\ install: >- ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-file' || 'mingw-w64-x86_64-file' }} @@ -109,7 +107,6 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libasprintf-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libintl-8.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libatomic-1.dll" "magic" - cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgcc_s_seh-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgomp-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libquadmath-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" From ef35884858e11715454489a42d04e792f6c35000 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:39:45 +0200 Subject: [PATCH 19/34] Fix --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index dc14a9f..c2cdca2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -94,6 +94,7 @@ jobs: uses: msys2/setup-msys2@v2.27.0 with: msystem: ${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }} + location: D:\ install: >- ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-file' || 'mingw-w64-x86_64-file' }} From a81e87429ce1d0e514aa20f8346a41d82c6cc9b4 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:48:05 +0200 Subject: [PATCH 20/34] Fix win32 --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c2cdca2..bce94f9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -108,6 +108,7 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libasprintf-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libintl-8.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libatomic-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgcc_s_dw2-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgomp-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libquadmath-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" From f905a0e52348f17e3066bcdc347bc7370adbf9ad Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:51:20 +0200 Subject: [PATCH 21/34] Fix win32 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index bce94f9..a3022ea 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -108,12 +108,12 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libasprintf-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libintl-8.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libatomic-1.dll" "magic" - cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgcc_s_dw2-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libgomp-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libquadmath-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libwinpthread-1.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From 09000e214bfa5604b42a17b090b92735eb890953 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 13:05:39 +0200 Subject: [PATCH 22/34] Add PATH hack --- .github/workflows/wheels.yml | 1 - magic/loader.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index a3022ea..c2cdca2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -113,7 +113,6 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" - cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libwinpthread-1.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 diff --git a/magic/loader.py b/magic/loader.py index c084298..fd4aea2 100644 --- a/magic/loader.py +++ b/magic/loader.py @@ -89,6 +89,7 @@ def _lib_candidates(): def load_lib(): + os.environ['PATH'] = here + os.pathsep + os.environ['PATH'] # for DLLs in site-packages exc = [] for lib in _lib_candidates(): # find_library returns None when lib not found From 70300502d763d9688d374af8fcec8fc6bae324a0 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 13:13:07 +0200 Subject: [PATCH 23/34] Check dependencies --- .github/workflows/wheels.yml | 5 +++++ magic/loader.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c2cdca2..52bd4ca 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -114,6 +114,11 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" + - name: Analyze DLL dependencies + if: runner.os == 'Windows' && endsWith(matrix.only, '32') + run: | + /msys64/mingw32/bin/objdump -p "magic/libmagic-1.dll" | grep "DLL" + - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 with: diff --git a/magic/loader.py b/magic/loader.py index fd4aea2..5892b26 100644 --- a/magic/loader.py +++ b/magic/loader.py @@ -52,6 +52,7 @@ def _lib_candidates_macos(): def _lib_candidates_windows(): """Yield possible libmagic library names on Windows.""" + os.environ['PATH'] = here + os.pathsep + os.environ['PATH'] # for DLLs in site-packages fnames = ( "libmagic", "magic1", @@ -89,7 +90,6 @@ def _lib_candidates(): def load_lib(): - os.environ['PATH'] = here + os.pathsep + os.environ['PATH'] # for DLLs in site-packages exc = [] for lib in _lib_candidates(): # find_library returns None when lib not found From 0f473392d7f3601fe827fca0bf28762519da562b Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 13:15:20 +0200 Subject: [PATCH 24/34] Check dependencies v2 --- .github/workflows/wheels.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 52bd4ca..010f9e8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -115,9 +115,10 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" - name: Analyze DLL dependencies - if: runner.os == 'Windows' && endsWith(matrix.only, '32') + if: runner.os == 'Windows' + shell: msys2 {0} run: | - /msys64/mingw32/bin/objdump -p "magic/libmagic-1.dll" | grep "DLL" + objdump -p "magic/libmagic-1.dll" | grep "DLL" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From 95e936503880c0e4383288f455132fae1fddaaf4 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 13:19:00 +0200 Subject: [PATCH 25/34] Copy additional win32 dlls --- .github/workflows/wheels.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 010f9e8..1aa318d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -114,11 +114,15 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" - - name: Analyze DLL dependencies - if: runner.os == 'Windows' - shell: msys2 {0} + - name: Copy additional 32-bit runtime DLLs + if: runner.os == 'Windows' && endsWith(matrix.only, '32') run: | - objdump -p "magic/libmagic-1.dll" | grep "DLL" + cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" + cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" + cp "/msys64/mingw32/bin/libzstd-1.dll" "magic" + cp "/msys64/mingw32/bin/libbz2-1.dll" "magic" + cp "/msys64/mingw32/bin/liblzma-5.dll" "magic" + cp "/msys64/mingw32/bin/libssp-0.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From 50e20406d4518d2d62df74601bb5f74d87c8c897 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 13:20:30 +0200 Subject: [PATCH 26/34] Copy additional win32 dlls v2 --- .github/workflows/wheels.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1aa318d..88dea8c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -119,9 +119,6 @@ jobs: run: | cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" - cp "/msys64/mingw32/bin/libzstd-1.dll" "magic" - cp "/msys64/mingw32/bin/libbz2-1.dll" "magic" - cp "/msys64/mingw32/bin/liblzma-5.dll" "magic" cp "/msys64/mingw32/bin/libssp-0.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above From 1fc6d9929b96753d1fe25d37024c3d77f53a0e57 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 15:35:23 +0200 Subject: [PATCH 27/34] Fix --- .github/workflows/wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 88dea8c..e84b2d9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -119,7 +119,6 @@ jobs: run: | cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" - cp "/msys64/mingw32/bin/libssp-0.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From b4002c5b7eef9c634eff87c13e54ffbab54f1bbe Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 15:56:45 +0200 Subject: [PATCH 28/34] Delete libgcc_s_dw2-1.dll --- .github/workflows/wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e84b2d9..2ef6cc5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -117,7 +117,6 @@ jobs: - name: Copy additional 32-bit runtime DLLs if: runner.os == 'Windows' && endsWith(matrix.only, '32') run: | - cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above From 37e21b88e9dd649c1d9006ab87a11ab9ceb9231d Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 15:59:44 +0200 Subject: [PATCH 29/34] Delete libwinpthread-1.dll --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 2ef6cc5..1368b2c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -117,7 +117,7 @@ jobs: - name: Copy additional 32-bit runtime DLLs if: runner.os == 'Windows' && endsWith(matrix.only, '32') run: | - cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" + cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From e43ac0de9ed403013c451397310304a58270be0d Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:10:32 +0200 Subject: [PATCH 30/34] Revert "Delete libwinpthread-1.dll" This reverts commit 37e21b88e9dd649c1d9006ab87a11ab9ceb9231d. --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1368b2c..2ef6cc5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -117,7 +117,7 @@ jobs: - name: Copy additional 32-bit runtime DLLs if: runner.os == 'Windows' && endsWith(matrix.only, '32') run: | - cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" + cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above timeout-minutes: 10 From 5a0f592e4d776e6bc213d470a9ca08ec5de40a16 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:10:57 +0200 Subject: [PATCH 31/34] Delete libiconv-2.dll --- .github/workflows/wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 2ef6cc5..14f5d2e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -112,7 +112,6 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libquadmath-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" - cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" - name: Copy additional 32-bit runtime DLLs if: runner.os == 'Windows' && endsWith(matrix.only, '32') From 4709a72999ed8b0f8c86e7c035344a8a822e460a Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:34:10 +0200 Subject: [PATCH 32/34] Revert "Delete libiconv-2.dll" This reverts commit 5a0f592e4d776e6bc213d470a9ca08ec5de40a16. --- .github/workflows/wheels.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 14f5d2e..e84b2d9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -112,10 +112,12 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libquadmath-0.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libstdc++-6.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" + cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" - name: Copy additional 32-bit runtime DLLs if: runner.os == 'Windows' && endsWith(matrix.only, '32') run: | + cp "/msys64/mingw32/bin/libgcc_s_dw2-1.dll" "magic" cp "/msys64/mingw32/bin/libwinpthread-1.dll" "magic" - uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above From 1de191309f357fe2f30bc6f4d3afd049dd5306f8 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:39:41 +0200 Subject: [PATCH 33/34] Test remnant --- magic/loader.py | 1 - 1 file changed, 1 deletion(-) diff --git a/magic/loader.py b/magic/loader.py index 5892b26..c084298 100644 --- a/magic/loader.py +++ b/magic/loader.py @@ -52,7 +52,6 @@ def _lib_candidates_macos(): def _lib_candidates_windows(): """Yield possible libmagic library names on Windows.""" - os.environ['PATH'] = here + os.pathsep + os.environ['PATH'] # for DLLs in site-packages fnames = ( "libmagic", "magic1", From 89e94f726e437d19f22e178f210acd1757317166 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 18 Mar 2025 23:24:09 +0200 Subject: [PATCH 34/34] Add comments --- .github/workflows/wheels.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e84b2d9..907e3a6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -89,6 +89,8 @@ jobs: if: runner.os == 'Linux' uses: docker/setup-qemu-action@v3 + # For Windows, grabbing latest file from MSYS2 is easier than building from source + # It's generally up to date ref https://packages.msys2.org/base/mingw-w64-file - name: Setup MSYS2 and install file if: runner.os == 'Windows' uses: msys2/setup-msys2@v2.27.0 @@ -98,6 +100,7 @@ jobs: install: >- ${{ endsWith(matrix.only, '32') && 'mingw-w64-i686-file' || 'mingw-w64-x86_64-file' }} + # The DLL dependency tree flattened out ref "Dependencies" https://packages.msys2.org/packages/mingw-w64-x86_64-file - name: Copy Windows ddl and mgc if: runner.os == 'Windows' run: | @@ -114,6 +117,7 @@ jobs: cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libcharset-1.dll" "magic" cp "/msys64/${{ endsWith(matrix.only, '32') && 'mingw32' || 'mingw64' }}/bin/libiconv-2.dll" "magic" + # These are needed additionally in the win32 wheel ref https://packages.msys2.org/packages/mingw-w64-i686-file - name: Copy additional 32-bit runtime DLLs if: runner.os == 'Windows' && endsWith(matrix.only, '32') run: |