Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pkg_resources dependency #316

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading