2727import subprocess as sp
2828from os import path as op
2929import argparse
30+ from importlib .resources import files , as_file # Python 3.9+
3031
31- # Prefer importlib.resources to avoid deprecated pkg_resources
32- try :
33- from importlib .resources import files , as_file # Python 3.9+
34-
35- _USE_IMPORTLIB_RESOURCES = True
36- except Exception : # pragma: no cover - fallback on very old Python
37- _USE_IMPORTLIB_RESOURCES = False
38- import pkg_resources # type: ignore
39-
40- __version__ = "0.2.2"
32+ __version__ = "0.2.6"
4133
4234
4335def example_stem_path ():
@@ -49,16 +41,13 @@ def example_stem_path():
4941 Filesystem path to the stem file (temp path if package is zipped)
5042 """
5143 rel_path = "data/The Easton Ellises - Falcon 69.stem.mp4"
52- if _USE_IMPORTLIB_RESOURCES :
53- ref = files ("stempeg" ).joinpath (rel_path )
54- try :
55- # as_file handles zipped/zip-safe installs by creating a tmp file
56- with as_file (ref ) as concrete_path :
57- return str (concrete_path )
58- except Exception :
59- return str (ref )
60- else : # fallback
61- return pkg_resources .resource_filename (__name__ , rel_path )
44+ ref = files ("stempeg" ).joinpath (rel_path )
45+ try :
46+ # as_file handles zipped/zip-safe installs by creating a tmp file
47+ with as_file (ref ) as concrete_path :
48+ return str (concrete_path )
49+ except Exception :
50+ return str (ref )
6251
6352
6453def default_metadata ():
@@ -70,15 +59,12 @@ def default_metadata():
7059 Filesystem path to the json file (temp path if package is zipped)
7160 """
7261 rel_path = "data/default_metadata.json"
73- if _USE_IMPORTLIB_RESOURCES :
74- ref = files ("stempeg" ).joinpath (rel_path )
75- try :
76- with as_file (ref ) as concrete_path :
77- return str (concrete_path )
78- except Exception :
79- return str (ref )
80- else : # fallback
81- return pkg_resources .resource_filename (__name__ , rel_path )
62+ ref = files ("stempeg" ).joinpath (rel_path )
63+ try :
64+ with as_file (ref ) as concrete_path :
65+ return str (concrete_path )
66+ except Exception :
67+ return str (ref )
8268
8369
8470def ffmpeg_version ():
0 commit comments