Skip to content

Use importlib.metadata from the standard library on Python 3.8+ #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
jobs:
fix_lint: null
docs: null
py38:
image: [linux]
py37:
image: [linux, windows, macOs]
py27:
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