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

pkg_resources deprecated with Python 3.12 #37

Merged
merged 5 commits into from
Dec 15, 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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- name: Git checkout
Expand Down Expand Up @@ -44,4 +44,4 @@ jobs:
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=12 --max-line-length=127 --statistics
flake8 . --count --exit-zero --max-complexity=12 --max-line-length=127 --statistics
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ This change log uses principles from `keep a changelog <http://keepachangelog.co
Added
^^^^^

- Test with Python 3.13 in CI workflow

Changed
^^^^^^^

- ``pkg_resources`` has been deprecated with Python 3.12. Replaced use of ``pkg_resources.iter_entry_points`` with ``importlib.metadata.entry_points`` for >= Python 3.8

Deprecated
^^^^^^^^^^
Expand Down
16 changes: 14 additions & 2 deletions dtoolcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import os
import sys

import datetime
import logging
Expand All @@ -11,7 +12,6 @@
import tempfile
import uuid

from pkg_resources import iter_entry_points
from collections import defaultdict

import dtoolcore.utils
Expand Down Expand Up @@ -59,7 +59,19 @@ def _generate_storage_broker_lookup():
"""Return dictionary of available storage brokers."""
logger.debug("In _generate_storage_broker_lookup...")
storage_broker_lookup = dict()
for entrypoint in iter_entry_points("dtool.storage_brokers"):

if sys.version_info >= (3, 8):
from importlib.metadata import entry_points
eps = entry_points()
if sys.version_info >= (3, 10):
entrypoints = eps.select(group="dtool.storage_brokers")
else:
entrypoints = eps.get("dtool.storage_brokers", [])
else:
from pkg_resources import iter_entry_points
entrypoints = iter_entry_points("dtool.storage_brokers")

for entrypoint in entrypoints:
StorageBroker = entrypoint.load()
key = StorageBroker.key
logger.debug("_gnerate_stroage_broker_lookup.key: {}".format(key))
Expand Down
Loading