From d3c2d7cbe2a2219ce09545ecc9af28d973f4002f Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Sun, 3 Feb 2019 12:54:54 -0500 Subject: [PATCH] Use pkg_resources instead of importlib_metadata to get installed version Removes importlib-metadata as a dependency. pkg_resources ships with setuptools, so it should be available in every reasonably-modern Python environment. --- pre_commit/constants.py | 4 ++-- setup.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pre_commit/constants.py b/pre_commit/constants.py index 996480a9..e753e4f7 100644 --- a/pre_commit/constants.py +++ b/pre_commit/constants.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from __future__ import unicode_literals -import importlib_metadata # TODO: importlib.metadata py38? +import pkg_resources CONFIG_FILE = '.pre-commit-config.yaml' MANIFEST_FILE = '.pre-commit-hooks.yaml' @@ -18,7 +18,7 @@ INSTALLED_STATE_VERSION = '1' # Bump when modifying `empty_template` LOCAL_REPO_VERSION = '1' -VERSION = importlib_metadata.version('pre_commit') +VERSION = str(pkg_resources.get_distribution('pre-commit').parsed_version) # `manual` is not invoked by any installed git hook. See #719 STAGES = ('commit', 'commit-msg', 'manual', 'push') diff --git a/setup.py b/setup.py index 240a7e3e..5fd7417a 100644 --- a/setup.py +++ b/setup.py @@ -38,8 +38,6 @@ setup( 'aspy.yaml', 'cfgv>=1.4.0', 'identify>=1.0.0', - # if this makes it into python3.8 move to extras_require - 'importlib-metadata', 'nodeenv>=0.11.1', 'pyyaml', 'six',