Skip to content

Commit

Permalink
replace pkg_resources with importlib.metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
lcjohnso committed Jun 13, 2024
1 parent f32c945 commit 684d085
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
import datetime
import os
import pkg_resources
import importlib.metadata
import sys
sys.path.insert(0, os.path.abspath('..'))

Expand Down Expand Up @@ -62,7 +62,7 @@
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = pkg_resources.require("panoptes_client")[0].version
release = importlib.metadata.version("panoptes_client")
# The short X.Y version.
version = '.'.join(release.split('.')[:2])

Expand Down
4 changes: 2 additions & 2 deletions panoptes_client/panoptes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import requests
import threading
import pkg_resources
import importlib.metadata

from datetime import datetime, timedelta
from redo import retrier
Expand Down Expand Up @@ -57,7 +57,7 @@ class Panoptes(object):
_http_headers = {
'default': {
'Accept': 'application/vnd.api+json; version=1',
'User-Agent': 'panoptes-python-client/version=' + pkg_resources.require('panoptes_client')[0].version
'User-Agent': 'panoptes-python-client/version=' + importlib.metadata.version('panoptes_client')
},
'GET': {},
'PUT': {
Expand Down
6 changes: 3 additions & 3 deletions panoptes_client/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
import magic
MEDIA_TYPE_DETECTION = 'magic'
except ImportError:
import pkg_resources
import importlib.metadata
try:
pkg_resources.require("python-magic")
importlib.metadata.version("python-magic")
logging.getLogger('panoptes_client').warn(
'Broken libmagic installation detected. The python-magic module is'
' installed but can\'t be imported. Please check that both '
'python-magic and the libmagic shared library are installed '
'correctly. Uploading media other than images may not work.'
)
except pkg_resources.DistributionNotFound:
except importlib.metadata.PackageNotFoundError:
pass
import imghdr
MEDIA_TYPE_DETECTION = 'imghdr'
Expand Down

0 comments on commit 684d085

Please sign in to comment.