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

install importlib_metadata on Python < 3.8 #1889

Closed
vphilippon opened this issue May 12, 2021 · 1 comment
Closed

install importlib_metadata on Python < 3.8 #1889

vphilippon opened this issue May 12, 2021 · 1 comment
Milestone

Comments

@vphilippon
Copy link
Contributor

click 8.0.0 now relies on importlib.metadata under certain conditions.
On Python 3.8, click will raise an error and ask the user to install the importlib_metadata backport package.

Ex:

Traceback (most recent call last):
  File "/path_to_my_venv/bin/myexecutable", line 8, in <module>
    sys.exit(cli())
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 1134, in __call__
    return self.main(*args, **kwargs)
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 1058, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 927, in make_context
    self.parse_args(ctx, args)
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 1621, in parse_args
    rest = super().parse_args(ctx, args)
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 1376, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 2352, in handle_parse_result
    value = self.process_value(ctx, value)
  File "/path_to_my_venv/lib/python3.6/site-packages/click/core.py", line 2314, in process_value
    value = self.callback(ctx, self, value)
  File "/path_to_my_venv/lib/python3.6/site-packages/click/decorators.py", line 380, in callback
    "Install 'importlib_metadata' to get the version on Python < 3.8."
RuntimeError: Install 'importlib_metadata' to get the version on Python < 3.8.

The user can install importlib_metadata, but I think Click could use environment markers to install the importlib_metadata backport package on Python 3.8, in the same manner that colorama is installed on Windows.

I will send a PR soon. Feel free to express any concerns, doubts or considerations to the project context that I've missed.

Environment:

  • Python version: 3.6
  • Click version: 8.0.0
@davidism davidism added this to the 8.0.1 milestone May 12, 2021
@davidism
Copy link
Member

I've relaxed my view on backport dependencies with environment markers since we added this code, so I'm fine with changing it.

@davidism davidism changed the title importlib_metadata missing. Suggestion: Install importlib_metadata on Python < 3.8 install importlib_metadata on Python < 3.8 May 19, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants