Skip to content

Commit b347a29

Browse files
authored
chore(wheelmaker): drop Python 2 support (#1545)
Python2 has been EOL for a while so this is just a small cleanup.
1 parent 955da69 commit b347a29

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Breaking changes:
6464
`incompatible_normalize_version` to `True` by default to enforce `PEP440`
6565
for wheel names built by `rules_python`.
6666

67+
* (tools/wheelmaker.py) drop support for Python 2 as only Python 3 is tested.
68+
6769
### Fixed
6870

6971
* Skip aliases for unloaded toolchains. Some Python versions that don't have full

tools/wheelmaker.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def arcname_from(name):
160160

161161
def add_string(self, filename, contents):
162162
"""Add given 'contents' as filename to the distribution."""
163-
if sys.version_info[0] > 2 and isinstance(contents, str):
163+
if isinstance(contents, str):
164164
contents = contents.encode("utf-8", "surrogateescape")
165165
zinfo = self._zipinfo(filename)
166166
self.writestr(zinfo, contents)
@@ -199,7 +199,7 @@ def add_recordfile(self):
199199
entries = self._record + [(record_path, b"", b"")]
200200
contents = b""
201201
for filename, digest, size in entries:
202-
if sys.version_info[0] > 2 and isinstance(filename, str):
202+
if isinstance(filename, str):
203203
filename = filename.lstrip("/").encode("utf-8", "surrogateescape")
204204
contents += b"%s,%s,%s\n" % (filename, digest, size)
205205

@@ -530,22 +530,14 @@ def main() -> None:
530530

531531
description = None
532532
if arguments.description_file:
533-
if sys.version_info[0] == 2:
534-
with open(arguments.description_file, "rt") as description_file:
535-
description = description_file.read()
536-
else:
537-
with open(
538-
arguments.description_file, "rt", encoding="utf-8"
539-
) as description_file:
540-
description = description_file.read()
533+
with open(
534+
arguments.description_file, "rt", encoding="utf-8"
535+
) as description_file:
536+
description = description_file.read()
541537

542538
metadata = None
543-
if sys.version_info[0] == 2:
544-
with open(arguments.metadata_file, "rt") as metadata_file:
545-
metadata = metadata_file.read()
546-
else:
547-
with open(arguments.metadata_file, "rt", encoding="utf-8") as metadata_file:
548-
metadata = metadata_file.read()
539+
with open(arguments.metadata_file, "rt", encoding="utf-8") as metadata_file:
540+
metadata = metadata_file.read()
549541

550542
if arguments.noincompatible_normalize_version:
551543
version_in_metadata = version

0 commit comments

Comments
 (0)