Python bindings: Port pkg_resources to importlib_resources for python < 3.9 (#2123)
* Python bindings: Port pkg_resources to importlib_resources for python < 3.9 Co-authored-by: Arusekk <floss@arusekk.pl> * GitHub Workflow: Bump uraimo/run-on-arch-action to v3 --------- Co-authored-by: Arusekk <floss@arusekk.pl>
This commit is contained in:
@@ -6,6 +6,9 @@ build-backend = "setuptools.build_meta"
|
||||
name = "unicorn"
|
||||
dynamic = ["version"]
|
||||
requires-python = ">= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*, != 3.5.*, != 3.6.*"
|
||||
dependencies = [
|
||||
"importlib_resources; python_version < '3.9'"
|
||||
]
|
||||
authors = [
|
||||
{ name = "Nguyen Anh Quynh", email = "quynh@gmail.com" },
|
||||
]
|
||||
|
||||
@@ -109,19 +109,17 @@ def __load_uc_lib() -> ctypes.CDLL:
|
||||
|
||||
# Loading attempts, in order
|
||||
# - user-provided environment variable
|
||||
# - pkg_resources can get us the path to the local libraries
|
||||
# - importlib.resources/importlib_resources can get us the path to the local libraries
|
||||
# - we can get the path to the local libraries by parsing our filename
|
||||
# - global load
|
||||
# - python's lib directory
|
||||
|
||||
if sys.version_info.minor >= 12:
|
||||
from importlib import resources
|
||||
|
||||
canonicals = resources.files('unicorn') / 'lib'
|
||||
if sys.version_info >= (3, 9):
|
||||
import importlib.resources as resources
|
||||
else:
|
||||
import pkg_resources
|
||||
import importlib_resources as resources
|
||||
|
||||
canonicals = pkg_resources.resource_filename('unicorn', 'lib')
|
||||
canonicals = resources.files('unicorn') / 'lib'
|
||||
|
||||
lib_locations = [
|
||||
os.getenv('LIBUNICORN_PATH'),
|
||||
|
||||
Reference in New Issue
Block a user