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

Handle deprecation of pkg_resources and favor importlib #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacebrowning
Copy link

Specifically, the Python 3.10 images on CircleCI no longer include pkg_resrouces as it's deprecated:

$ honcho start
Traceback (most recent call last):
  File "/home/circleci/myproject/.venv/bin/honcho", line 5, in <module>
    from honcho.command import main
  File "/home/circleci/myproject/.venv/lib/python3.10/site-packages/honcho/command.py", line 10, in <module>
    from pkg_resources import iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'

Starting in Python 3.8, importlib.metdata is the preferred way to find entry points.

@jacebrowning jacebrowning marked this pull request as ready for review September 19, 2022 15:52
@RealOrangeOne
Copy link

pkg_resources is no longer included in virtual environments from Python 3.12 - making this PR required to run on 3.12.

Alternatively, manually installing setuptools (pip install setuptools) also solves the problem.

@nickstenning as this is going to slowly start becoming more of an issue - any chance of a release? 🙂

Comment on lines +35 to +44
try:
from pkg_resources import iter_entry_points # Python 3.7-3.9

export_choices = dict((_export.name, _export)
for _export in iter_entry_points('honcho_exporters'))
except ImportError:
from importlib.metadata import entry_points # Python 3.10+

export_choices = dict((_export.name, _export)
for _export in entry_points(group='honcho_exporters'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should really be flipped -- prefer importlib.metadata and if it's not available then fall back to (deprecated) pkg_resources -- otherwise this will still trigger deprecation warnings even on systems where importlib.metadata would avoid such warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants