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

Python 3.12 not supported #140

Closed
henryiii opened this issue Oct 19, 2023 · 2 comments
Closed

Python 3.12 not supported #140

henryiii opened this issue Oct 19, 2023 · 2 comments
Assignees
Labels
bug Something isn't working high priority

Comments

@henryiii
Copy link

henryiii commented Oct 19, 2023

I'm getting the following:

Traceback (most recent call last):
  File "/Users/henryschreiner/git/scikit-build/scikit-build-cli/.venv/bin/rich-click", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/henryschreiner/git/scikit-build/scikit-build-cli/.venv/lib/python3.12/site-packages/rich_click/cli.py", line 103, in main
    scripts = {script.name: script for script in entry_points().get("console_scripts", [])}
                                                 ^^^^^^^^^^^^^^^^^^
AttributeError: 'EntryPoints' object has no attribute 'get'

The return from entry_points as changed to EntryPoints in importlib_metadata 5 and Python 3.12. I think 3.10+ also have EntryPoints, but it provided a Mapping back-compat interface.

If it helps, this is my 3.8+ wrapper from other projects:

# _compat/importlib/metadata.py
from __future__ import annotations

import importlib.metadata
import sys


def entry_points(*, group: str) -> importlib.metadata.EntryPoints:  # type: ignore[name-defined]
    """
    Wrapper for entry_points to support Python 3.8+ instead of 3.10+.
    """
    if sys.version_info >= (3, 10):
        return importlib.metadata.entry_points(group=group)

    epg = importlib.metadata.entry_points()

    return epg.get(group, [])

And my 3.7+ wrapper:

# _compat/importlib/metadata.py
from __future__ import annotations

import sys

if sys.version_info < (3, 8):
    import importlib_metadata as _metadata
else:
    import importlib.metadata as _metadata

__all__ = ["entry_points"]


def entry_points(*, group: str) -> _metadata.EntryPoints:
    if sys.version_info >= (3, 10):
        return _metadata.entry_points(group=group)

    epg = _metadata.entry_points()

    if sys.version_info < (3, 8) and hasattr(epg, "select"):
        return epg.select(group=group)  # type: ignore[no-any-return, no-untyped-call]

    return epg.get(group, [])  # type: ignore[no-any-return, attr-defined]


def __dir__() -> list[str]:
    return __all__
@ewels ewels added bug Something isn't working high priority labels Oct 21, 2023
@dwreeves dwreeves self-assigned this Oct 30, 2023
@dwreeves
Copy link
Collaborator

Oh no! I'll get on this as soon as I can. Thanks for raising this issue.

@dwreeves
Copy link
Collaborator

dwreeves commented Nov 1, 2023

Hi @henryiii . Sorry for the delay; I was away for much of the past 2 weeks, so only just noticed this a couple days ago.

rich-click==1.7.1 has been released and resolves this issue! 😄

Thank you for bringing this to our attention. Let us know if you have any more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

3 participants