salimma / rpms / python-tox

Forked from rpms/python-tox 4 years ago
Clone
80602e3
From dab74691cd1cd55621c943fc869f8ee821746ff6 Mon Sep 17 00:00:00 2001
80602e3
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
80602e3
Date: Mon, 8 Jul 2019 19:08:17 +0200
80602e3
Subject: [PATCH] Use importlib.metadata from the standard library on Python
80602e3
 3.8+
80602e3
80602e3
Fixes https://github.com/tox-dev/tox/issues/1367
80602e3
---
80602e3
 CONTRIBUTORS                            | 1 +
80602e3
 setup.cfg                               | 2 +-
80602e3
 src/tox/config/__init__.py              | 2 +-
80602e3
 src/tox/session/commands/show_config.py | 2 +-
80602e3
 src/tox/util/stdlib.py                  | 5 +++++
80602e3
 tox.ini                                 | 2 +-
80602e3
 6 files changed, 10 insertions(+), 4 deletions(-)
80602e3
80602e3
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
80602e3
index 39d848b..ad0168f 100644
80602e3
--- a/CONTRIBUTORS
80602e3
+++ b/CONTRIBUTORS
80602e3
@@ -58,6 +58,7 @@ Mattieu Agopian
80602e3
 Michael Manganiello
80602e3
 Mickaël Schoentgen
80602e3
 Mikhail Kyshtymov
80602e3
+Miro Hrončok
80602e3
 Monty Taylor
80602e3
 Morgan Fainberg
80602e3
 Nick Douma
80602e3
diff --git a/setup.cfg b/setup.cfg
80602e3
index 3950ea3..c2bb1c2 100644
80602e3
--- a/setup.cfg
80602e3
+++ b/setup.cfg
80602e3
@@ -37,7 +37,7 @@ classifiers =
80602e3
 packages = find:
80602e3
 python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
80602e3
 install_requires = 
80602e3
-	importlib-metadata >= 0.12, <1
80602e3
+	importlib-metadata >= 0.12, <1;python_version<"3.8"
80602e3
 	packaging >= 14
80602e3
 	pluggy >= 0.12.0, <1
80602e3
 	py >= 1.4.17, <2
80602e3
diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py
80602e3
index c1a3239..849b31f 100644
80602e3
--- a/src/tox/config/__init__.py
80602e3
+++ b/src/tox/config/__init__.py
80602e3
@@ -15,7 +15,6 @@ from fnmatch import fnmatchcase
80602e3
 from subprocess import list2cmdline
80602e3
 from threading import Thread
80602e3
 
80602e3
-import importlib_metadata
80602e3
 import pluggy
80602e3
 import py
80602e3
 import toml
80602e3
@@ -34,6 +33,7 @@ from tox.reporter import (
80602e3
     verbosity1,
80602e3
 )
80602e3
 from tox.util.path import ensure_empty_dir
80602e3
+from tox.util.stdlib import importlib_metadata
80602e3
 
80602e3
 from .parallel import ENV_VAR_KEY as PARALLEL_ENV_VAR_KEY
80602e3
 from .parallel import add_parallel_config, add_parallel_flags
80602e3
diff --git a/src/tox/session/commands/show_config.py b/src/tox/session/commands/show_config.py
80602e3
index 11c5cf2..efb713a 100644
80602e3
--- a/src/tox/session/commands/show_config.py
80602e3
+++ b/src/tox/session/commands/show_config.py
80602e3
@@ -1,13 +1,13 @@
80602e3
 import sys
80602e3
 from collections import OrderedDict
80602e3
 
80602e3
-import importlib_metadata
80602e3
 from packaging.requirements import Requirement
80602e3
 from packaging.utils import canonicalize_name
80602e3
 from six import StringIO
80602e3
 from six.moves import configparser
80602e3
 
80602e3
 from tox import reporter
80602e3
+from tox.util.stdlib import importlib_metadata
80602e3
 
80602e3
 DO_NOT_SHOW_CONFIG_ATTRIBUTES = (
80602e3
     "interpreters",
80602e3
diff --git a/src/tox/util/stdlib.py b/src/tox/util/stdlib.py
80602e3
index 0b25859..5f687b7 100644
80602e3
--- a/src/tox/util/stdlib.py
80602e3
+++ b/src/tox/util/stdlib.py
80602e3
@@ -3,6 +3,11 @@ import threading
80602e3
 from contextlib import contextmanager
80602e3
 from tempfile import TemporaryFile
80602e3
 
80602e3
+if sys.version_info >= (3, 8):
80602e3
+    from importlib import metadata as importlib_metadata  # noqa
80602e3
+else:
80602e3
+    import importlib_metadata  # noqa
80602e3
+
80602e3
 
80602e3
 def is_main_thread():
80602e3
     """returns true if we are within the main thread"""
80602e3
diff --git a/tox.ini b/tox.ini
80602e3
index fa5b321..fcb1418 100644
80602e3
--- a/tox.ini
80602e3
+++ b/tox.ini
80602e3
@@ -139,7 +139,7 @@ include_trailing_comma = True
80602e3
 force_grid_wrap = 0
80602e3
 line_length = 99
80602e3
 known_first_party = tox,tests
80602e3
-known_third_party = apiclient,docutils,filelock,flaky,freezegun,git,httplib2,importlib_metadata,oauth2client,packaging,pathlib2,pluggy,py,pytest,setuptools,six,sphinx,toml
80602e3
+known_third_party = apiclient,docutils,filelock,flaky,freezegun,git,httplib2,oauth2client,packaging,pathlib2,pluggy,py,pytest,setuptools,six,sphinx,toml
80602e3
 
80602e3
 [testenv:release]
80602e3
 description = do a release, required posarg of the version number
80602e3
-- 
80602e3
2.21.0
80602e3