diff options
author | Bernát Gábor <gaborjbernat@gmail.com> | 2023-04-19 16:05:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 16:05:21 -0700 |
commit | 04af5026d8eff9ab34cd6f4a47e2f9de4f10a25c (patch) | |
tree | 7a7beb20e885285b6838f75db5c647a4d20317fc /tasks | |
parent | cdd7eb129e5a31b5ff6779f00bc7621908962626 (diff) | |
download | virtualenv-04af5026d8eff9ab34cd6f4a47e2f9de4f10a25c.tar.gz |
Drop Python 2 support (#2548)
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/__main__zipapp.py | 14 | ||||
-rw-r--r-- | tasks/make_zipapp.py | 12 | ||||
-rw-r--r-- | tasks/release.py | 5 | ||||
-rwxr-xr-x | tasks/update_embedded.py | 2 | ||||
-rw-r--r-- | tasks/upgrade_wheels.py | 6 |
5 files changed, 27 insertions, 12 deletions
diff --git a/tasks/__main__zipapp.py b/tasks/__main__zipapp.py index 87d4589..e48620b 100644 --- a/tasks/__main__zipapp.py +++ b/tasks/__main__zipapp.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import os import sys @@ -7,7 +9,7 @@ ABS_HERE = os.path.abspath(os.path.dirname(__file__)) NEW_IMPORT_SYSTEM = sys.version_info[0] == 3 -class VersionPlatformSelect(object): +class VersionPlatformSelect: def __init__(self): self.archive = ABS_HERE self._zip_file = zipfile.ZipFile(ABS_HERE, "r") @@ -20,11 +22,11 @@ class VersionPlatformSelect(object): per_version = json.loads(self.get_data(of_file).decode("utf-8")) all_platforms = per_version[version] if version in per_version else per_version["3.9"] content = all_platforms.get("==any", {}) # start will all platforms - not_us = "!={}".format(sys.platform) + not_us = f"!={sys.platform}" for key, value in all_platforms.items(): # now override that with not platform if key.startswith("!=") and key != not_us: content.update(value) - content.update(all_platforms.get("=={}".format(sys.platform), {})) # and finish it off with our platform + content.update(all_platforms.get(f"=={sys.platform}", {})) # and finish it off with our platform return content def __enter__(self): @@ -61,19 +63,19 @@ class VersionPlatformSelect(object): yield result def __repr__(self): - return "{}(path={})".format(self.__class__.__name__, ABS_HERE) + return f"{self.__class__.__name__}(path={ABS_HERE})" def _register_distutils_finder(self): if "distlib" not in self.modules: return - class DistlibFinder(object): + class DistlibFinder: def __init__(self, path, loader): self.path = path self.loader = loader def find(self, name): - class Resource(object): + class Resource: def __init__(self, content): self.bytes = content diff --git a/tasks/make_zipapp.py b/tasks/make_zipapp.py index 67286f6..5303f41 100644 --- a/tasks/make_zipapp.py +++ b/tasks/make_zipapp.py @@ -1,4 +1,6 @@ """https://docs.python.org/3/library/zipapp.html""" +from __future__ import annotations + import argparse import io import json @@ -20,7 +22,7 @@ from packaging.requirements import Requirement HERE = Path(__file__).parent.absolute() -VERSIONS = [f"3.{i}" for i in range(10, 5, -1)] +VERSIONS = [f"3.{i}" for i in range(10, 6, -1)] def main(): @@ -223,7 +225,13 @@ class WheelDownloader: def run_suppress_output(cmd, stop_print_on_fail=False): - process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + process = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + encoding="utf-8", + ) out, err = process.communicate() if stop_print_on_fail and process.returncode != 0: print(f"exit with {process.returncode} of {' '.join(quote(i) for i in cmd)}", file=sys.stdout) diff --git a/tasks/release.py b/tasks/release.py index 8724bf2..0d5ac38 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -1,7 +1,8 @@ """Handles creating a release PR""" +from __future__ import annotations + from pathlib import Path from subprocess import check_call -from typing import Tuple from git import Commit, Head, Remote, Repo, TagReference from packaging.version import Version @@ -25,7 +26,7 @@ def main(version_str: str) -> None: print("All done! ✨ 🍰 ✨") -def create_release_branch(repo: Repo, version: Version) -> Tuple[Remote, Head]: +def create_release_branch(repo: Repo, version: Version) -> tuple[Remote, Head]: print("create release branch from upstream main") upstream = get_upstream(repo) upstream.fetch() diff --git a/tasks/update_embedded.py b/tasks/update_embedded.py index 2f44531..3f159f0 100755 --- a/tasks/update_embedded.py +++ b/tasks/update_embedded.py @@ -1,5 +1,7 @@ """Helper script to rebuild virtualenv.py from virtualenv_support""" +from __future__ import annotations + import codecs import os import re diff --git a/tasks/upgrade_wheels.py b/tasks/upgrade_wheels.py index 76750da..beb2df7 100644 --- a/tasks/upgrade_wheels.py +++ b/tasks/upgrade_wheels.py @@ -2,6 +2,8 @@ Helper script to rebuild virtualenv_support. Downloads the wheel files using pip """ +from __future__ import annotations + import os import shutil import subprocess @@ -15,7 +17,7 @@ from threading import Thread STRICT = "UPGRADE_ADVISORY" not in os.environ BUNDLED = ["pip", "setuptools", "wheel"] -SUPPORT = list(reversed([(2, 7)] + [(3, i) for i in range(5, 13)])) +SUPPORT = [(3, i) for i in range(7, 13)] DEST = Path(__file__).resolve().parents[1] / "src" / "virtualenv" / "seed" / "wheels" / "embed" @@ -81,7 +83,7 @@ def run(): lines.append("") changelog = "\n".join(lines) print(changelog) - if len(lines) >= 3: + if len(lines) >= 4: (Path(__file__).parents[1] / "docs" / "changelog" / "u.bugfix.rst").write_text(changelog, encoding="utf-8") support_table = OrderedDict((".".join(str(j) for j in i), []) for i in SUPPORT) for package in sorted(new_batch.keys()): |