Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build platform-specific wheels containing libmagic #294

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ec952d7
Build platform-specific wheels containing libmagic
ddelange Sep 7, 2023
a437409
Move persmissions into job scope, remove ABI3 reference
ddelange Sep 15, 2023
4a715e2
Switch to PyPI trusted publishing
ddelange Nov 13, 2023
1adc0a5
Add CIBW_TEST_COMMAND and indent Makefile
ddelange Jan 25, 2024
20e2dc9
Merge branch 'master' of https://github.com/ahupp/python-magic into a…
ddelange Jan 25, 2024
090b1d4
Fix CI for macos
ddelange Jan 25, 2024
20d8fee
Add dependabot.yml
ddelange Jan 25, 2024
85d4422
Migrate actions/upload-artifact@v4
ddelange Jan 25, 2024
2efa36d
Ensure magic.mgc packaged in wheel gets recognised
ddelange Jan 25, 2024
0b43bc6
Add note about --no-binary to the installation instructions
ddelange Apr 1, 2024
05df4f9
Separate mac versions
ddelange Apr 4, 2024
d2972b9
Update cibuildwheel
ddelange Apr 4, 2024
e182ae1
Bump pypa/[email protected]
ddelange Apr 4, 2024
94718d5
Bump cibuildwheel docker images
ddelange Apr 11, 2024
359e007
Revert "Bump cibuildwheel docker images"
ddelange Apr 11, 2024
bb9c685
Move magic.mgc injection into Magic class
ddelange Apr 11, 2024
b0fddf3
Build on more recent cibw images
ddelange Apr 11, 2024
dc075e9
Use hls mp4 (recent libmagic only) for testing
ddelange Apr 11, 2024
144132d
Revert "Use hls mp4 (recent libmagic only) for testing"
ddelange Apr 11, 2024
fe62a26
Install from source
ddelange Apr 23, 2024
f7bbb03
Documentation and readability
ddelange Apr 24, 2024
2e6104e
Build macos wheels with maximum backwards compatibility
ddelange May 6, 2024
ca4def3
Use CIBW_SKIP
ddelange May 6, 2024
ba87ffd
Apply suggestions from code review
ddelange May 20, 2024
e112de3
Merge branch 'master' of ahupp/python-magic into abi3-wheels
ddelange May 22, 2024
eba05b6
Fix compat.py now that bundled libmagic is preferred
ddelange May 22, 2024
8381a96
Fix https://github.com/ahupp/python-magic/issues/321
ddelange May 22, 2024
9c5f955
Use sudo on ubuntu-latest in ci.yml
ddelange May 22, 2024
e6d5ed0
Fix sudo not available on windows-latest
ddelange May 22, 2024
50504a2
Merge branch 'ahupp:master' into abi3-wheels
ddelange May 22, 2024
9357f27
Add entries in CHANGELOG
ddelange May 23, 2024
53d099b
Merge branch 'master' of https://github.com/ahupp/python-magic into a…
ddelange May 26, 2024
9bf2e9c
Fix test
ddelange May 26, 2024
f7341ce
PR Suggestions
ddelange May 26, 2024
da5b330
Apply suggestions from code review
ddelange May 28, 2024
258efa4
Revert partially: fix install on Windows
ddelange May 29, 2024
3a55538
Merge branch 'master' into abi3-wheels
ddelange Jun 18, 2024
65fb61c
Apply suggestions from code review
ddelange Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions magic/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

def _lib_candidates_linux():
"""Yield possible libmagic library names on Linux."""
prefixes = ('libmagic.so.1', 'libmagic.so')
fnames = ('libmagic.so.1', 'libmagic.so')

for i in prefixes:
for fname in fnames:
# libmagic bundled in the wheel
yield os.path.join(here, i)
yield os.path.join(here, fname)
# libmagic in the current working directory
yield os.path.join(os.path.abspath('.'), i)
yield os.path.join(os.path.abspath('.'), fname)
# libmagic install from source default destination path
yield os.path.join('/usr/local/lib', i)
yield os.path.join('/usr/local/lib', fname)
# on some linux systems (musl/alpine), find_library('magic') returns None
# first try finding libmagic using ldconfig
# otherwise fall back to /usr/lib/
yield subprocess.check_output(
"( ldconfig -p | grep '{0}' | grep -o '/.*' ) || echo '/usr/lib/{0}'".format(i),
"( ldconfig -p | grep '{0}' | grep -o '/.*' ) || echo '/usr/lib/{0}'".format(fname),
shell=True,
universal_newlines=True,
).strip()
Expand All @@ -43,13 +43,13 @@ def _lib_candidates_macos():
'/opt/homebrew/lib',
] + glob.glob('/usr/local/Cellar/libmagic/*/lib')

for i in paths:
yield os.path.join(i, 'libmagic.dylib')
for path in paths:
yield os.path.join(path, 'libmagic.dylib')


def _lib_candidates_windows():
"""Yield possible libmagic library names on Windows."""
prefixes = (
fnames = (
"libmagic",
"magic1",
"magic-1",
Expand All @@ -58,13 +58,13 @@ def _lib_candidates_windows():
"msys-magic-1",
)

for i in prefixes:
for fname in fnames:
# libmagic bundled in the wheel
yield os.path.join(here, '%s.dll' % i)
yield os.path.join(here, '%s.dll' % fname)
# libmagic in the current working directory
yield os.path.join(os.path.abspath('.'), '%s.dll' % i)
yield os.path.join(os.path.abspath('.'), '%s.dll' % fname)
# find_library searches in %PATH% but not the current directory
yield find_library(i)
yield find_library(fname)
ddelange marked this conversation as resolved.
Show resolved Hide resolved


def _lib_candidates():
Expand Down