Skip to content

Commit 2efa36d

Browse files
committed
Ensure magic.mgc packaged in wheel gets recognised
1 parent 85d4422 commit 2efa36d

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

magic/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,11 @@ def magic_descriptor(cookie, fd):
354354

355355

356356
def magic_load(cookie, filename):
357-
try:
358-
return _magic_load(cookie, coerce_filename(filename))
359-
except MagicException:
357+
mime_db = os.path.join(os.path.dirname(__file__), 'magic.mgc')
358+
if os.path.exists(mime_db):
360359
# wheels package the mime database in this directory
361-
filename = os.path.join(os.path.dirname(__file__), 'magic.mgc')
362-
return _magic_load(cookie, coerce_filename(filename))
360+
return _magic_load(cookie, coerce_filename(mime_db))
361+
return _magic_load(cookie, coerce_filename(filename))
363362

364363

365364
magic_setflags = libmagic.magic_setflags

magic/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ctypes.util import find_library
22
import ctypes
33
import glob
4-
import os.path
4+
import os
55
import subprocess
66
import sys
77

0 commit comments

Comments
 (0)