python-passlib/no-pkg_resources.patch
2023-08-03 06:29:46 +00:00

31 lines
1.1 KiB
Diff

Index: passlib-1.7.4/passlib/pwd.py
===================================================================
--- passlib-1.7.4.orig/passlib/pwd.py
+++ passlib-1.7.4/passlib/pwd.py
@@ -13,8 +13,8 @@ except ImportError:
from collections import MutableMapping
from math import ceil, log as logf
import logging; log = logging.getLogger(__name__)
-import pkg_resources
import os
+import sys
# site
# pkg
from passlib import exc
@@ -122,7 +122,14 @@ def _open_asset_path(path, encoding=None
if not sep:
raise ValueError("asset path must be absolute file path "
"or use 'pkg.name:sub/path' format: %r" % (path,))
- return pkg_resources.resource_stream(package, subpath)
+ if sys.version_info >= (3, 9):
+ # We can use the new and shiny importlib.resources
+ import importlib.resources
+ return importlib.resources.files(package).joinpath(subpath).open('rb')
+ else:
+ # Fallback to pkg_resources
+ import pkg_resources
+ return pkg_resources.resource_stream(package, subpath)
#: type aliases