Skip to content

Commit

Permalink
Modify canonicals import
Browse files Browse the repository at this point in the history
  • Loading branch information
elicn committed Sep 29, 2024
1 parent 038b92d commit 0c34496
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions bindings/python/unicorn/unicorn_py3/unicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,19 @@ def _load_lib(path: Path, lib_name: str):
# - we can get the path to the local libraries by parsing our filename
# - global load
# - python's lib directory
canonicals = []

try:

if sys.version_info.minor >= 12:
from importlib import resources
canonicals.append(
resources.files("unicorn") / 'lib'
)
except:
try:
import pkg_resources
canonicals.append(
pkg_resources.resource_filename("unicorn", 'lib')
)
except:
# maybe importlib_resources, but ignore for now
pass


canonicals = resources.files('unicorn') / 'lib'
else:
import pkg_resources

canonicals = pkg_resources.resource_filename('unicorn', 'lib')

lib_locations = [
os.getenv('LIBUNICORN_PATH'),
] + canonicals + [
canonicals,
PurePath(inspect.getfile(__load_uc_lib)).parent / 'lib',
'',
r'/usr/local/lib' if sys.platform == 'darwin' else r'/usr/lib64',
Expand Down

0 comments on commit 0c34496

Please sign in to comment.