Skip to content

Commit 8ea0adb

Browse files
committed
fix(sphinxext) PY39 deprecated pkg_resources.open_bin()
1 parent 48024fa commit 8ea0adb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

graphtik/sphinxext/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,12 @@ def _purge_old_document_images(app: Sphinx, env: BuildEnvironment, docname: str)
475475

476476

477477
def _stage_my_pkg_resource(inp_fname, out_fpath):
478-
with pkg_resources.open_binary(__package__, inp_fname) as inp, open(
479-
out_fpath, "wb"
480-
) as out:
478+
try:
479+
inp_file = (pkg_resources.files(__package__) / inp_fname).open("rb")
480+
except AttributeError:
481+
# Python < PY3.9
482+
inp_file = pkg_resources.open_binary(__package__, inp_fname)
483+
with inp_file as inp, open(out_fpath, "wb") as out:
481484
copyfileobj(inp, out)
482485

483486

0 commit comments

Comments
 (0)