Skip to content

Commit

Permalink
Use importlib.metadata from the standard library on Python 3.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Jul 8, 2019
1 parent e4c7752 commit 718704f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Mattieu Agopian
Michael Manganiello
Mickaël Schoentgen
Mikhail Kyshtymov
Miro Hrončok
Monty Taylor
Morgan Fainberg
Nick Douma
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog/1367.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Replace ``importlib_metadata`` backport with ``importlib.metadata``
from the standard library on Python ``3.8+`` - by :user:`hroncok`
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ classifiers =
packages = find:
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
install_requires =
importlib-metadata >= 0.12, <1
importlib-metadata >= 0.12, <1;python_version<"3.8"
packaging >= 14
pluggy >= 0.12.0, <1
py >= 1.4.17, <2
Expand Down
2 changes: 1 addition & 1 deletion src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from subprocess import list2cmdline
from threading import Thread

import importlib_metadata
import pluggy
import py
import toml
Expand All @@ -34,6 +33,7 @@
verbosity1,
)
from tox.util.path import ensure_empty_dir
from tox.util.stdlib import importlib_metadata

from .parallel import ENV_VAR_KEY as PARALLEL_ENV_VAR_KEY
from .parallel import add_parallel_config, add_parallel_flags
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/commands/show_config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import sys
from collections import OrderedDict

import importlib_metadata
from packaging.requirements import Requirement
from packaging.utils import canonicalize_name
from six import StringIO
from six.moves import configparser

from tox import reporter
from tox.util.stdlib import importlib_metadata

DO_NOT_SHOW_CONFIG_ATTRIBUTES = (
"interpreters",
Expand Down
5 changes: 5 additions & 0 deletions src/tox/util/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from contextlib import contextmanager
from tempfile import TemporaryFile

if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata # noqa
else:
import importlib_metadata # noqa


def is_main_thread():
"""returns true if we are within the main thread"""
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ include_trailing_comma = True
force_grid_wrap = 0
line_length = 99
known_first_party = tox,tests
known_third_party = apiclient,docutils,filelock,flaky,freezegun,git,httplib2,importlib_metadata,oauth2client,packaging,pathlib2,pluggy,py,pytest,setuptools,six,sphinx,toml
known_third_party = apiclient,docutils,filelock,flaky,freezegun,git,httplib2,oauth2client,packaging,pathlib2,pluggy,py,pytest,setuptools,six,sphinx,toml
[testenv:release]
description = do a release, required posarg of the version number
Expand Down

0 comments on commit 718704f

Please sign in to comment.