Skip to content

Commit f6c42eb

Browse files
hroncokgaborbernat
authored andcommitted
Use importlib.metadata from the standard library on Python 3.8+ (#1368)
* Use importlib.metadata from the standard library on Python 3.8+ Fixes #1367 * Azure Pipelines: Add Python 3.8
1 parent e4c7752 commit f6c42eb

File tree

8 files changed

+14
-4
lines changed

8 files changed

+14
-4
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Mattieu Agopian
5858
Michael Manganiello
5959
Mickaël Schoentgen
6060
Mikhail Kyshtymov
61+
Miro Hrončok
6162
Monty Taylor
6263
Morgan Fainberg
6364
Nick Douma

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
jobs:
3030
fix_lint: null
3131
docs: null
32+
py38:
33+
image: [linux]
3234
py37:
3335
image: [linux, windows, macOs]
3436
py27:

docs/changelog/1367.misc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Replace ``importlib_metadata`` backport with ``importlib.metadata``
2+
from the standard library on Python ``3.8+`` - by :user:`hroncok`

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ classifiers =
3838
packages = find:
3939
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
4040
install_requires =
41-
importlib-metadata >= 0.12, <1
41+
importlib-metadata >= 0.12, <1;python_version<"3.8"
4242
packaging >= 14
4343
pluggy >= 0.12.0, <1
4444
py >= 1.4.17, <2

src/tox/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from subprocess import list2cmdline
1616
from threading import Thread
1717

18-
import importlib_metadata
1918
import pluggy
2019
import py
2120
import toml
@@ -34,6 +33,7 @@
3433
verbosity1,
3534
)
3635
from tox.util.path import ensure_empty_dir
36+
from tox.util.stdlib import importlib_metadata
3737

3838
from .parallel import ENV_VAR_KEY as PARALLEL_ENV_VAR_KEY
3939
from .parallel import add_parallel_config, add_parallel_flags

src/tox/session/commands/show_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import sys
22
from collections import OrderedDict
33

4-
import importlib_metadata
54
from packaging.requirements import Requirement
65
from packaging.utils import canonicalize_name
76
from six import StringIO
87
from six.moves import configparser
98

109
from tox import reporter
10+
from tox.util.stdlib import importlib_metadata
1111

1212
DO_NOT_SHOW_CONFIG_ATTRIBUTES = (
1313
"interpreters",

src/tox/util/stdlib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
from contextlib import contextmanager
44
from tempfile import TemporaryFile
55

6+
if sys.version_info >= (3, 8):
7+
from importlib import metadata as importlib_metadata # noqa
8+
else:
9+
import importlib_metadata # noqa
10+
611

712
def is_main_thread():
813
"""returns true if we are within the main thread"""

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ include_trailing_comma = True
139139
force_grid_wrap = 0
140140
line_length = 99
141141
known_first_party = tox,tests
142-
known_third_party = apiclient,docutils,filelock,flaky,freezegun,git,httplib2,importlib_metadata,oauth2client,packaging,pathlib2,pluggy,py,pytest,setuptools,six,sphinx,toml
142+
known_third_party = apiclient,docutils,filelock,flaky,freezegun,git,httplib2,oauth2client,packaging,pathlib2,pluggy,py,pytest,setuptools,six,sphinx,toml
143143
144144
[testenv:release]
145145
description = do a release, required posarg of the version number

0 commit comments

Comments
 (0)