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 #1890

Merged
merged 2 commits into from
May 19, 2021
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Unreleased
- Fix some types that weren't available in Python 3.6.0. :issue:`1882`
- Fix type checking for iterating over ``ProgressBar`` object.
:issue:`1892`
- The ``importlib_metadata`` backport package is installed on Python <
3.8. :issue:`1889`


Version 8.0.0
Expand Down
4 changes: 0 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ idna==2.10
# via requests
imagesize==1.2.0
# via sphinx
importlib-metadata==4.0.1
# via -r requirements/tests.in
iniconfig==1.1.1
# via pytest
jinja2==2.11.3
Expand Down Expand Up @@ -133,8 +131,6 @@ virtualenv==20.4.6
# via
# pre-commit
# tox
zipp==3.4.1
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
1 change: 0 additions & 1 deletion requirements/tests.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pytest
importlib_metadata
4 changes: 0 additions & 4 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#
attrs==21.2.0
# via pytest
importlib-metadata==4.0.1
# via -r requirements/tests.in
iniconfig==1.1.1
# via pytest
packaging==20.9
Expand All @@ -22,5 +20,3 @@ pytest==6.2.4
# via -r requirements/tests.in
toml==0.10.2
# via pytest
zipp==3.4.1
# via importlib-metadata
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from setuptools import setup

setup(name="click", install_requires=["colorama; platform_system == 'Windows'"])
setup(
name="click",
install_requires=[
"colorama; platform_system == 'Windows'",
"importlib-metadata; python_version < '3.8'",
],
)
10 changes: 1 addition & 9 deletions src/click/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,7 @@ def callback(ctx: Context, param: Parameter, value: bool) -> None:
from importlib import metadata # type: ignore
except ImportError:
# Python < 3.8
try:
import importlib_metadata as metadata # type: ignore
except ImportError:
metadata = None

if metadata is None:
raise RuntimeError(
"Install 'importlib_metadata' to get the version on Python < 3.8."
)
import importlib_metadata as metadata # type: ignore

try:
version = metadata.version(package_name) # type: ignore
Expand Down