Skip to content

Commit

Permalink
Ensure magic.mgc packaged in wheel gets recognised
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed Jan 25, 2024
1 parent 85d4422 commit 2efa36d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions magic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,11 @@ def magic_descriptor(cookie, fd):


def magic_load(cookie, filename):
try:
return _magic_load(cookie, coerce_filename(filename))
except MagicException:
mime_db = os.path.join(os.path.dirname(__file__), 'magic.mgc')
if os.path.exists(mime_db):
# wheels package the mime database in this directory
filename = os.path.join(os.path.dirname(__file__), 'magic.mgc')
return _magic_load(cookie, coerce_filename(filename))
return _magic_load(cookie, coerce_filename(mime_db))
return _magic_load(cookie, coerce_filename(filename))


magic_setflags = libmagic.magic_setflags
Expand Down
2 changes: 1 addition & 1 deletion magic/loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ctypes.util import find_library
import ctypes
import glob
import os.path
import os
import subprocess
import sys

Expand Down

0 comments on commit 2efa36d

Please sign in to comment.