Skip to content

Commit

Permalink
Replace pkg_resources with importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Oct 2, 2023
1 parent 3fb7e9a commit 71160af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
author = 'The Foreman'

try:
import pkg_resources
package = pkg_resources.require("obsah")[0]
version = package.version
release = package.version
from importlib import metadata
version = release = metadata.version('obsah')
except:
# The short X.Y version
version = ''
Expand Down
10 changes: 3 additions & 7 deletions obsah/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import sys
from collections import namedtuple
from functools import total_ordering
from importlib import resources

import yaml
import pkg_resources

try:
import argcomplete
Expand Down Expand Up @@ -207,12 +207,8 @@ def data_path():
"""
path = os.environ.get('OBSAH_DATA')
if path is None:
path = pkg_resources.resource_filename(__name__, 'data')
if not os.path.isabs(path):
# this is essentially a workaround for
# https://github.com/pytest-dev/pytest-xdist/issues/414
distribution = pkg_resources.get_distribution('obsah')
path = os.path.join(distribution.location, path)
# TODO: deprecated in 3.11
path = resources.path(__name__, 'data')

return path

Expand Down

0 comments on commit 71160af

Please sign in to comment.