Skip to content

Commit

Permalink
fix(sphinxext) PY39 deprecated pkg_resources.open_bin()
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed May 2, 2023
1 parent f7a011d commit 1f53adf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions graphtik/sphinxext/__init__.py
Expand Up @@ -475,9 +475,12 @@ def _purge_old_document_images(app: Sphinx, env: BuildEnvironment, docname: str)


def _stage_my_pkg_resource(inp_fname, out_fpath):
with pkg_resources.open_binary(__package__, inp_fname) as inp, open(
out_fpath, "wb"
) as out:
try:
inp_file = (pkg_resources.files(__package__) / inp_fname).open("rb")
except AttributeError:
# Python < PY3.9
inp_file = pkg_resources.open_binary(__package__, inp_fname)
with inp_file as inp, open(out_fpath, "wb") as out:
copyfileobj(inp, out)


Expand Down

0 comments on commit 1f53adf

Please sign in to comment.