summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2021-12-22 15:37:46 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2021-12-22 15:37:46 +0200
commit2fae593de291a9963f932ffe0e18241b9f95e5c8 (patch)
tree88d992270728397b8bebf6daf038761e3135f849 /src
parentc716c87ffa528ac9a31de3ed3217058848dc2cd2 (diff)
downloadwheel-git-2fae593de291a9963f932ffe0e18241b9f95e5c8.tar.gz
Dropped support for unmaintained Python versions
Diffstat (limited to 'src')
-rw-r--r--src/wheel/bdist_wheel.py22
-rw-r--r--src/wheel/cli/__init__.py2
-rwxr-xr-xsrc/wheel/cli/convert.py4
-rw-r--r--src/wheel/cli/pack.py6
-rw-r--r--src/wheel/cli/unpack.py6
-rw-r--r--src/wheel/pkginfo.py56
-rw-r--r--src/wheel/util.py28
-rw-r--r--src/wheel/wheelfile.py18
8 files changed, 36 insertions, 106 deletions
diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py
index 80e43d0..84a3fcf 100644
--- a/src/wheel/bdist_wheel.py
+++ b/src/wheel/bdist_wheel.py
@@ -14,6 +14,7 @@ import warnings
from collections import OrderedDict
from distutils.core import Command
from distutils import log as logger
+from email.generator import BytesGenerator
from io import BytesIO
from glob import iglob
from shutil import rmtree
@@ -29,10 +30,6 @@ from .vendored.packaging import tags
from .wheelfile import WheelFile
from . import __version__ as wheel_version
-if sys.version_info < (3,):
- from email.generator import Generator as BytesGenerator
-else:
- from email.generator import BytesGenerator
safe_name = pkg_resources.safe_name
safe_version = pkg_resources.safe_version
@@ -69,8 +66,7 @@ def get_flag(var, fallback, expected=True, warn=True):
def get_abi_tag():
- """Return the ABI tag based on SOABI (if available) or emulate SOABI
- (CPython 2, PyPy)."""
+ """Return the ABI tag based on SOABI (if available) or emulate SOABI (PyPy)."""
soabi = get_config_var('SOABI')
impl = tags.interpreter_name()
if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'):
@@ -81,19 +77,14 @@ def get_abi_tag():
hasattr(sys, 'gettotalrefcount'),
warn=(impl == 'cp')):
d = 'd'
+
if get_flag('WITH_PYMALLOC',
impl == 'cp',
warn=(impl == 'cp' and
sys.version_info < (3, 8))) \
and sys.version_info < (3, 8):
m = 'm'
- if get_flag('Py_UNICODE_SIZE',
- sys.maxunicode == 0x10ffff,
- expected=4,
- warn=(impl == 'cp' and
- sys.version_info < (3, 3))) \
- and sys.version_info < (3, 3):
- u = 'u'
+
abi = '%s%s%s%s%s' % (impl, tags.interpreter_version(), d, m, u)
elif soabi and soabi.startswith('cpython-'):
abi = 'cp' + soabi.split('-')[1]
@@ -105,6 +96,7 @@ def get_abi_tag():
abi = soabi.replace('.', '_').replace('-', '_')
else:
abi = None
+
return abi
@@ -374,10 +366,6 @@ class bdist_wheel(Command):
def write_wheelfile(self, wheelfile_base, generator='bdist_wheel (' + wheel_version + ')'):
from email.message import Message
- # Workaround for Python 2.7 for when "generator" is unicode
- if sys.version_info < (3,) and not isinstance(generator, str):
- generator = generator.encode('utf-8')
-
msg = Message()
msg['Wheel-Version'] = '1.0' # of the spec
msg['Generator'] = generator
diff --git a/src/wheel/cli/__init__.py b/src/wheel/cli/__init__.py
index 95740bf..d41dcfd 100644
--- a/src/wheel/cli/__init__.py
+++ b/src/wheel/cli/__init__.py
@@ -2,8 +2,6 @@
Wheel command-line utility.
"""
-from __future__ import print_function
-
import argparse
import os
import sys
diff --git a/src/wheel/cli/convert.py b/src/wheel/cli/convert.py
index 154f1b1..b502daf 100755
--- a/src/wheel/cli/convert.py
+++ b/src/wheel/cli/convert.py
@@ -1,7 +1,6 @@
import os.path
import re
import shutil
-import sys
import tempfile
import zipfile
from distutils import dist
@@ -261,8 +260,7 @@ def convert(files, dest_dir, verbose):
conv = wininst2wheel
if verbose:
- print("{}... ".format(installer))
- sys.stdout.flush()
+ print("{}... ".format(installer), flush=True)
conv(installer, dest_dir)
if verbose:
diff --git a/src/wheel/cli/pack.py b/src/wheel/cli/pack.py
index 9403c51..04d858d 100644
--- a/src/wheel/cli/pack.py
+++ b/src/wheel/cli/pack.py
@@ -1,8 +1,5 @@
-from __future__ import print_function
-
import os.path
import re
-import sys
from wheel.cli import WheelError
from wheel.wheelfile import WheelFile
@@ -75,8 +72,7 @@ def pack(directory, dest_dir, build_number):
# Repack the wheel
wheel_path = os.path.join(dest_dir, '{}-{}.whl'.format(name_version, tagline))
with WheelFile(wheel_path, 'w') as wf:
- print("Repacking wheel as {}...".format(wheel_path), end='')
- sys.stdout.flush()
+ print("Repacking wheel as {}...".format(wheel_path), end='', flush=True)
wf.write_files(directory)
print('OK')
diff --git a/src/wheel/cli/unpack.py b/src/wheel/cli/unpack.py
index 2e9857a..8aa8180 100644
--- a/src/wheel/cli/unpack.py
+++ b/src/wheel/cli/unpack.py
@@ -1,7 +1,4 @@
-from __future__ import print_function
-
import os.path
-import sys
from ..wheelfile import WheelFile
@@ -18,8 +15,7 @@ def unpack(path, dest='.'):
with WheelFile(path) as wf:
namever = wf.parsed_filename.group('namever')
destination = os.path.join(dest, namever)
- print("Unpacking to: {}...".format(destination), end='')
- sys.stdout.flush()
+ print("Unpacking to: {}...".format(destination), end='', flush=True)
wf.extractall(destination)
print('OK')
diff --git a/src/wheel/pkginfo.py b/src/wheel/pkginfo.py
index 115be45..0470a1d 100644
--- a/src/wheel/pkginfo.py
+++ b/src/wheel/pkginfo.py
@@ -1,43 +1,23 @@
"""Tools for reading and writing PKG-INFO / METADATA without caring
about the encoding."""
+from email.generator import BytesGenerator
from email.parser import Parser
-try:
- unicode
- _PY3 = False
-except NameError:
- _PY3 = True
-
-if not _PY3:
- from email.generator import Generator
-
- def read_pkg_info_bytes(bytestr):
- return Parser().parsestr(bytestr)
-
- def read_pkg_info(path):
- with open(path, "r") as headers:
- message = Parser().parse(headers)
- return message
-
- def write_pkg_info(path, message):
- with open(path, 'w') as metadata:
- Generator(metadata, mangle_from_=False, maxheaderlen=0).flatten(message)
-else:
- from email.generator import BytesGenerator
-
- def read_pkg_info_bytes(bytestr):
- headers = bytestr.decode(encoding="ascii", errors="surrogateescape")
- message = Parser().parsestr(headers)
- return message
-
- def read_pkg_info(path):
- with open(path, "r",
- encoding="ascii",
- errors="surrogateescape") as headers:
- message = Parser().parse(headers)
- return message
-
- def write_pkg_info(path, message):
- with open(path, "wb") as out:
- BytesGenerator(out, mangle_from_=False, maxheaderlen=0).flatten(message)
+
+def read_pkg_info_bytes(bytestr):
+ headers = bytestr.decode(encoding="ascii", errors="surrogateescape")
+ message = Parser().parsestr(headers)
+ return message
+
+
+def read_pkg_info(path):
+ with open(path, "r", encoding="ascii", errors="surrogateescape") as headers:
+ message = Parser().parse(headers)
+
+ return message
+
+
+def write_pkg_info(path, message):
+ with open(path, "wb") as out:
+ BytesGenerator(out, mangle_from_=False, maxheaderlen=0).flatten(message)
diff --git a/src/wheel/util.py b/src/wheel/util.py
index 3ae2b44..a1f1e3b 100644
--- a/src/wheel/util.py
+++ b/src/wheel/util.py
@@ -1,25 +1,10 @@
import base64
-import io
-import sys
-if sys.version_info[0] < 3:
- text_type = unicode # noqa: F821
-
- StringIO = io.BytesIO
-
- def native(s, encoding='utf-8'):
- if isinstance(s, unicode): # noqa: F821
- return s.encode(encoding)
- return s
-else:
- text_type = str
-
- StringIO = io.StringIO
-
- def native(s, encoding='utf-8'):
- if isinstance(s, bytes):
- return s.decode(encoding)
+def native(s, encoding='utf-8'):
+ if isinstance(s, bytes):
+ return s.decode(encoding)
+ else:
return s
@@ -41,6 +26,7 @@ def as_unicode(s):
def as_bytes(s):
- if isinstance(s, text_type):
+ if isinstance(s, str):
return s.encode('utf-8')
- return s
+ else:
+ return s
diff --git a/src/wheel/wheelfile.py b/src/wheel/wheelfile.py
index 21e7361..2295306 100644
--- a/src/wheel/wheelfile.py
+++ b/src/wheel/wheelfile.py
@@ -1,28 +1,16 @@
-from __future__ import print_function
-
import csv
import hashlib
import os.path
import re
import stat
-import sys
import time
from collections import OrderedDict
from distutils import log as logger
+from io import StringIO, TextIOWrapper
from zipfile import ZIP_DEFLATED, ZipInfo, ZipFile
from wheel.cli import WheelError
-from wheel.util import urlsafe_b64decode, as_unicode, native, urlsafe_b64encode, as_bytes, StringIO
-
-if sys.version_info >= (3,):
- from io import TextIOWrapper
-
- def read_csv(fp):
- return csv.reader(TextIOWrapper(fp, newline='', encoding='utf-8'))
-else:
- def read_csv(fp):
- for line in csv.reader(fp):
- yield [column.decode('utf-8') for column in line]
+from wheel.util import urlsafe_b64decode, as_unicode, native, urlsafe_b64encode, as_bytes
# Non-greedy matching of an optional build number may be too clever (more
# invalid wheel filenames will match). Separate regex for .dist-info?
@@ -71,7 +59,7 @@ class WheelFile(ZipFile):
raise WheelError('Missing {} file'.format(self.record_path))
with record:
- for line in read_csv(record):
+ for line in csv.reader(TextIOWrapper(record, newline='', encoding='utf-8')):
path, hash_sum, size = line
if not hash_sum:
continue