Skip to content

Commit

Permalink
Fix for API change in importlib_resources
Browse files Browse the repository at this point in the history
The fixed get_copyright_notice will only work in python>=3.7.
The overhead for keeping compatibility with more versions is not
warranted.

This function may be removed in the future anyway.
  • Loading branch information
coldfix committed Sep 20, 2023
1 parent 7fbe3b4 commit 7e141e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ zip_safe = false
include_package_data = true
python_requires = >=3.6
install_requires =
importlib_resources
numpy
minrpc>=0.1.0

Expand Down
7 changes: 6 additions & 1 deletion src/cpymad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@


def get_copyright_notice() -> str:
from importlib_resources import read_text
try:
from importlib.resources import files
def read_text(package, resource, **kwargs):
return files(package).joinpath(resource).read_text(**kwargs)
except ImportError:
from importlib.resources import read_text
return read_text('cpymad.COPYING', 'cpymad.rst', encoding='utf-8')

0 comments on commit 7e141e0

Please sign in to comment.