mirror of https://github.com/pypa/pep517.git
Browse Source
Match pip support Pythons and remove support for end-of-life Pythons. pip has not support Python 2 since 21.0 (2021-01-23). For dates on when these environments went EOL, see: https://devguide.python.org/devcycle/#end-of-life-branches Removing support for Python2 allows for several simplifications: - Remove use of toml package in favor of tomli - Remove compat.py - Replace io.open with builtin open - Replace tempdir function with tempfile.TemporaryDirectory - Replace mkdir_p function with os.makedirs - Remove use of mock package in favor of unittest.mock - Remove import from future module - Remove unnecessary inheritance from object Refs #90pull/131/head

20 changed files with 72 additions and 198 deletions
@ -1,11 +1,8 @@
|
||||
pytest |
||||
pytest-flake8 |
||||
flake8 < 4 # https://github.com/tholo/pytest-flake8/issues/81 |
||||
pytest-forward-compatibility; python_version<'3' |
||||
mock ; python_version<'3.6' |
||||
testpath |
||||
toml ; python_version<'3.6' |
||||
tomli ; python_version>='3.6' |
||||
tomli |
||||
setuptools>=30 |
||||
importlib_metadata ; python_version<'3.8' |
||||
zipp ; python_version<'3.8' |
||||
|
@ -1,2 +1 @@
|
||||
toml ; python_version<'3.6' |
||||
tomli ; python_version>='3.6' |
||||
tomli |
||||
|
@ -1,50 +0,0 @@
|
||||
"""Python 2/3 compatibility""" |
||||
import io |
||||
import json |
||||
import sys |
||||
|
||||
# Handle reading and writing JSON in UTF-8, on Python 3 and 2. |
||||
|
||||
if sys.version_info[0] >= 3: |
||||
# Python 3 |
||||
def write_json(obj, path, **kwargs): |
||||
with open(path, 'w', encoding='utf-8') as f: |
||||
json.dump(obj, f, **kwargs) |
||||
|
||||
def read_json(path): |
||||
with open(path, 'r', encoding='utf-8') as f: |
||||
return json.load(f) |
||||
|
||||
else: |
||||
# Python 2 |
||||
def write_json(obj, path, **kwargs): |
||||
with open(path, 'wb') as f: |
||||
json.dump(obj, f, encoding='utf-8', **kwargs) |
||||
|
||||
def read_json(path): |
||||
with open(path, 'rb') as f: |
||||
return json.load(f) |
||||
|
||||
|
||||
# FileNotFoundError |
||||
|
||||
try: |
||||
FileNotFoundError = FileNotFoundError |
||||
except NameError: |
||||
FileNotFoundError = IOError |
||||
|
||||
|
||||
if sys.version_info < (3, 6): |
||||
from toml import load as _toml_load # noqa: F401 |
||||
|
||||
def toml_load(f): |
||||
w = io.TextIOWrapper(f, encoding="utf8", newline="") |
||||
try: |
||||
return _toml_load(w) |
||||
finally: |
||||
w.detach() |
||||
|
||||
from toml import TomlDecodeError as TOMLDecodeError # noqa: F401 |
||||
else: |
||||
from tomli import TOMLDecodeError # noqa: F401 |
||||
from tomli import load as toml_load # noqa: F401 |
Loading…
Reference in new issue