Skip to content

Commit

Permalink
fix imageio on Mac ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
domlysz committed May 6, 2024
1 parent ce9bd26 commit da078bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion core/lib/imageio/core/fetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def get_remote_file(fname, directory=None, force_download=False):
fname : str
The path to the file on the local system.
"""
_url_root = 'https://github.com/imageio/imageio-binaries/raw/master/'
#_url_root = 'https://github.com/imageio/imageio-binaries/raw/master/'
_url_root = 'https://github.com/domlysz/freeimage_bin/raw/master/'
url = _url_root + fname
fname = op.normcase(fname) # convert to native
# Get dirs to look for the resource
Expand Down
15 changes: 12 additions & 3 deletions core/lib/imageio/core/util.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import time
import struct
from warnings import warn
import platform

import numpy as np

Expand Down Expand Up @@ -516,19 +517,27 @@ def get_platform():
Get a string that specifies the platform more specific than
sys.platform does. The result can be: linux32, linux64, win32,
win64, osx32, osx64. Other platforms may be added in the future.
win64, osx32, osx64, osx-arm64. Other platforms may be added in the future.
"""
# Get platform
if sys.platform.startswith('linux'):
plat = 'linux%i'
elif sys.platform.startswith('win'):
plat = 'win%i'
elif sys.platform.startswith('darwin'):
plat = 'osx%i'
if platform.machine() == 'arm64':
plat = 'osx-arm64'
else:
plat = 'osx%i'
else: # pragma: no cover
return None

return plat % (struct.calcsize('P') * 8) # 32 or 64 bits
# Only perform string formatting when plat contains '%i'
if '%i' in plat:
return plat % (struct.calcsize('P') * 8) # 32 or 64 bits
else:
return plat



def has_module(module_name):
Expand Down
8 changes: 5 additions & 3 deletions core/lib/imageio/plugins/_freeimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
FNAME_PER_PLATFORM = {
'osx32': 'libfreeimage-3.16.0-osx10.6.dylib', # universal library
'osx64': 'libfreeimage-3.16.0-osx10.6.dylib',
'win32': 'FreeImage-3.15.4-win32.dll',
'win64': 'FreeImage-3.15.1-win64.dll',
'osx-arm64': 'libfreeimage.3.18.0.dylib',
'win32': 'FreeImage-3.18.0-win32.dll',
'win64': 'FreeImage-3.18.0-win64.dll',
'linux32': 'libfreeimage-3.16.0-linux32.so',
'linux64': 'libfreeimage-3.16.0-linux64.so',
}
Expand All @@ -51,7 +52,8 @@ def get_freeimage_lib():
plat = get_platform()
if plat and plat in FNAME_PER_PLATFORM:
try:
return get_remote_file('freeimage/' + FNAME_PER_PLATFORM[plat])
#return get_remote_file('freeimage/' + FNAME_PER_PLATFORM[plat])
return get_remote_file(FNAME_PER_PLATFORM[plat])
except InternetNotAllowedError:
pass
except RuntimeError as e: # pragma: no cover
Expand Down

0 comments on commit da078bf

Please sign in to comment.