Changeset - 3727959383d0
[Not reviewed]
0 2 0
Lance Edgar (lance) - 4 months ago 2024-07-02 09:58:30
lance@edbob.org
fix: use `importlib_resources` before python 3.9
2 files changed with 9 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rattail/files.py
Show inline comments
 
@@ -35,11 +35,6 @@ import tempfile
 
import errno
 
import warnings
 

	
 
try:
 
    import importlib.resources as importlib_resources
 
except ImportError:
 
    import importlib_resources
 

	
 
from rattail.exceptions import PathNotFound
 

	
 

	
 
@@ -222,9 +217,15 @@ def resource_path(path):
 
    :rtype: string
 
    """
 
    if not os.path.isabs(path) and ':' in path:
 

	
 
        try:
 
            from importlib.resources import files, as_file
 
        except ImportError: # python < 3.9
 
            from importlib_resources import files, as_file
 

	
 
        package, filename = path.split(':')
 
        ref = importlib_resources.files(package) / filename
 
        with importlib_resources.as_file(ref) as path:
 
        ref = files(package) / filename
 
        with as_file(ref) as path:
 
            return str(path)
 

	
 
    return path
setup.cfg
Show inline comments
 
@@ -39,7 +39,7 @@ install_requires =
 
        colander
 
        humanize
 
        importlib_metadata ; python_version < '3.8'
 
        importlib_resources ; python_version < '3.8'
 
        importlib_resources ; python_version < '3.9'
 
        lockfile
 
        makefun
 
        Mako
0 comments (0 inline, 0 general)