Skip to content
Myr

install importlib_metadata on Python < 3.8

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Use environment markers to have importlib_metadata backport package installed automatically on Python < 3.8, easing user experience.

authored by Vincent Philippon · committed by David Lord · parent b03a043 · Browse files · 3 files+10 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−10 removed

  • other:+10 added−10 removed

3 files+10 added−10 removed

modified:src/click/decorators.py+1 added-9 removed
368 unmodified lines
369 try:370 from importlib import metadata # type: ignore371 except ImportError:372 # Python < 3.8373 try:374 import importlib_metadata as metadata # type: ignore373 import importlib_metadata as metadata # type: ignore375 except ImportError:376 metadata = None374378 if metadata is None:379 raise RuntimeError(380 "Install 'importlib_metadata' to get the version on Python < 3.8."381 )382375 try:376 version = metadata.version(package_name) # type: ignore377 except metadata.PackageNotFoundError: # type: ignore378 raise RuntimeError(
56 unmodified lines
modified:CHANGES.rst+2 added
10 unmodified lines
11 operations on the arbitrary object. :issue:`1885`12- Fix some types that weren't available in Python 3.6.0. :issue:`1882`13- Fix type checking for iterating over ``ProgressBar`` object.14 :issue:`1892`15- The ``importlib_metadata`` backport package is installed on Python <16 3.8. :issue:`1889`171819Version 8.0.020-------------
854 unmodified lines
modified:setup.py+7 added-1 removed
1from setuptools import setup23setup(name="click", install_requires=["colorama; platform_system == 'Windows'"])3setup(4 name="click",5 install_requires=[6 "colorama; platform_system == 'Windows'",7 "importlib-metadata; python_version < '3.8'",8 ],9)