Skip to content

Commit a41eaab

Browse files
committed
remove pkg
1 parent 701c681 commit a41eaab

File tree

2 files changed

+16
-30
lines changed

2 files changed

+16
-30
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
setup(
1717
name="stempeg",
18-
version="0.2.5",
18+
version="0.2.6",
1919
description="Read and write stem/multistream audio files",
2020
long_description=long_description,
2121
long_description_content_type="text/markdown",

stempeg/__init__.py

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,9 @@
2727
import subprocess as sp
2828
from os import path as op
2929
import 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

4335
def 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

6453
def 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

8470
def ffmpeg_version():

0 commit comments

Comments
 (0)