Skip to content

Commit

Permalink
remove uses of pkg_resources from template files
Browse files Browse the repository at this point in the history
  • Loading branch information
mcflugen committed Mar 4, 2024
1 parent 7b91576 commit 5193552
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#! /usr/bin/env python
import pkg_resources
import importlib.metadata


__version__ = pkg_resources.get_distribution("{{ cookiecutter.package_name }}").version
__version__ = importlib.metadata.version("{{ cookiecutter.package_name }}")


from .bmi import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
from .lib import {{ classes|join(', ') }}

{%- else %}
import pkg_resources
if sys.version_info >= (3, 12): # pragma: no cover (PY12+)
import importlib.resources as importlib_resources
else: # pragma: no cover (<PY312)
import importlib_resources


{% for babelized_class, component in cookiecutter.components|dictsort %}

Expand All @@ -20,7 +24,7 @@

{%- for cls in classes %}
{{ cls }}.__name__ = "{{ cls }}"
{{ cls }}.METADATA = pkg_resources.resource_filename(__name__ , "data/{{ cls }}")
{{ cls }}.METADATA = str(importlib_resources.files(__name__) / "data/{{ cls }}")
{%- endfor %}

{%- endif %}
Expand Down

0 comments on commit 5193552

Please sign in to comment.