From a160f815aa3dc48621fbf310a36da186ec9b59d0 Mon Sep 17 00:00:00 2001 From: Jeremy Volkman Date: Fri, 5 May 2023 10:17:55 -0700 Subject: [PATCH] Bundle auditwheel==5.4.0 --- pyproject.toml | 2 +- .../_vendor/auditwheel/__main__.py | 2 + .../_vendor/auditwheel/condatools.py | 7 +-- .../_vendor/auditwheel/elfutils.py | 24 +++++----- src/repairwheel/_vendor/auditwheel/error.py | 3 ++ .../_vendor/auditwheel/genericpkgctx.py | 6 +-- .../_vendor/auditwheel/hashfile.py | 2 + src/repairwheel/_vendor/auditwheel/lddtree.py | 46 ++++++++++--------- src/repairwheel/_vendor/auditwheel/libc.py | 2 + src/repairwheel/_vendor/auditwheel/main.py | 6 +-- .../_vendor/auditwheel/main_addtag.py | 2 + .../_vendor/auditwheel/main_lddtree.py | 2 + .../_vendor/auditwheel/main_repair.py | 2 + .../_vendor/auditwheel/main_show.py | 2 + .../_vendor/auditwheel/musllinux.py | 2 + src/repairwheel/_vendor/auditwheel/patcher.py | 9 ++-- .../_vendor/auditwheel/policy/__init__.py | 25 ++++++---- .../auditwheel/policy/external_references.py | 16 ++++--- .../auditwheel/policy/versioned_symbols.py | 11 +++-- src/repairwheel/_vendor/auditwheel/repair.py | 20 ++++---- src/repairwheel/_vendor/auditwheel/tmpdirs.py | 17 +++---- src/repairwheel/_vendor/auditwheel/tools.py | 8 ++-- .../_vendor/auditwheel/wheel_abi.py | 9 ++-- .../_vendor/auditwheel/wheeltools.py | 16 ++++--- src/repairwheel/_vendor/vendor.txt | 2 +- tools/vendoring/patches/auditwheel.patch | 6 +-- 26 files changed, 142 insertions(+), 107 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 502ff5e..d91c4e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "repairwheel" -version = "0.2.3" +version = "0.2.4" description = "Repair any wheel, anywhere" readme = "README.md" requires-python = ">= 3.7" diff --git a/src/repairwheel/_vendor/auditwheel/__main__.py b/src/repairwheel/_vendor/auditwheel/__main__.py index 21eba35..db616dd 100644 --- a/src/repairwheel/_vendor/auditwheel/__main__.py +++ b/src/repairwheel/_vendor/auditwheel/__main__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from .main import main diff --git a/src/repairwheel/_vendor/auditwheel/condatools.py b/src/repairwheel/_vendor/auditwheel/condatools.py index 3c3ea78..4a4041a 100644 --- a/src/repairwheel/_vendor/auditwheel/condatools.py +++ b/src/repairwheel/_vendor/auditwheel/condatools.py @@ -1,8 +1,9 @@ """Context managers like those in wheeltools.py for unpacking conda packages. """ +from __future__ import annotations + import os -from typing import List, Optional from .tmpdirs import InTemporaryDirectory from .tools import tarbz2todir @@ -22,13 +23,13 @@ def __enter__(self) -> str: class InCondaPkgCtx(InCondaPkg): def __init__(self, in_conda_pkg: str) -> None: super().__init__(in_conda_pkg) - self.path: Optional[str] = None + self.path: str | None = None def __enter__(self): self.path = super().__enter__() return self - def iter_files(self) -> List[str]: + def iter_files(self) -> list[str]: if self.path is None: raise ValueError("This function should be called from context manager") files = os.path.join(self.path, "info", "files") diff --git a/src/repairwheel/_vendor/auditwheel/elfutils.py b/src/repairwheel/_vendor/auditwheel/elfutils.py index a319350..2ae94cd 100644 --- a/src/repairwheel/_vendor/auditwheel/elfutils.py +++ b/src/repairwheel/_vendor/auditwheel/elfutils.py @@ -1,6 +1,8 @@ +from __future__ import annotations + from os.path import basename from pathlib import Path -from typing import Dict, Iterator, List, Optional, Set, Tuple +from typing import Iterator from elftools.common.exceptions import ELFError from elftools.elf.elffile import ELFFile @@ -8,7 +10,7 @@ from .lddtree import parse_ld_paths -def elf_read_dt_needed(fn: str) -> List[str]: +def elf_read_dt_needed(fn: str) -> list[str]: needed = [] with open(fn, "rb") as f: elf = ELFFile(f) @@ -23,7 +25,7 @@ def elf_read_dt_needed(fn: str) -> List[str]: return needed -def elf_file_filter(paths: Iterator[str]) -> Iterator[Tuple[str, ELFFile]]: +def elf_file_filter(paths: Iterator[str]) -> Iterator[tuple[str, ELFFile]]: """Filter through an iterator of filenames and load up only ELF files """ @@ -41,7 +43,7 @@ def elf_file_filter(paths: Iterator[str]) -> Iterator[Tuple[str, ELFFile]]: continue -def elf_find_versioned_symbols(elf: ELFFile) -> Iterator[Tuple[str, str]]: +def elf_find_versioned_symbols(elf: ELFFile) -> Iterator[tuple[str, str]]: section = elf.get_section_by_name(".gnu.version_r") if section is not None: @@ -65,7 +67,6 @@ def elf_find_ucs2_symbols(elf: ELFFile) -> Iterator[str]: and sym["st_shndx"] == "SHN_UNDEF" and sym["st_info"]["type"] == "STT_FUNC" ): - yield sym.name @@ -84,7 +85,7 @@ def elf_references_PyFPE_jbuf(elf: ELFFile) -> bool: return False -def elf_is_python_extension(fn: str, elf: ELFFile) -> Tuple[bool, Optional[int]]: +def elf_is_python_extension(fn: str, elf: ELFFile) -> tuple[bool, int | None]: modname = basename(fn).split(".", 1)[0] module_init_f = { "init" + modname: 2, @@ -102,14 +103,13 @@ def elf_is_python_extension(fn: str, elf: ELFFile) -> Tuple[bool, Optional[int]] and sym["st_shndx"] != "SHN_UNDEF" and sym["st_info"]["type"] == "STT_FUNC" ): - return True, module_init_f[sym.name] return False, None -def elf_read_rpaths(fn: str) -> Dict[str, List[str]]: - result = {"rpaths": [], "runpaths": []} # type: Dict[str, List[str]] +def elf_read_rpaths(fn: str) -> dict[str, list[str]]: + result: dict[str, list[str]] = {"rpaths": [], "runpaths": []} with open(fn, "rb") as f: elf = ELFFile(f) @@ -139,7 +139,7 @@ def is_subdir(path: str, directory: str) -> bool: return True -def get_undefined_symbols(path: str) -> Set[str]: +def get_undefined_symbols(path: str) -> set[str]: undef_symbols = set() with open(path, "rb") as f: elf = ELFFile(f) @@ -153,8 +153,8 @@ def get_undefined_symbols(path: str) -> Set[str]: def filter_undefined_symbols( - path: str, symbols: Dict[str, List[str]] -) -> Dict[str, List[str]]: + path: str, symbols: dict[str, list[str]] +) -> dict[str, list[str]]: if not symbols: return {} undef_symbols = set("*") | get_undefined_symbols(path) diff --git a/src/repairwheel/_vendor/auditwheel/error.py b/src/repairwheel/_vendor/auditwheel/error.py index c95348c..6938ea3 100644 --- a/src/repairwheel/_vendor/auditwheel/error.py +++ b/src/repairwheel/_vendor/auditwheel/error.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + class AuditwheelException(Exception): pass diff --git a/src/repairwheel/_vendor/auditwheel/genericpkgctx.py b/src/repairwheel/_vendor/auditwheel/genericpkgctx.py index 0841adb..750f807 100644 --- a/src/repairwheel/_vendor/auditwheel/genericpkgctx.py +++ b/src/repairwheel/_vendor/auditwheel/genericpkgctx.py @@ -1,12 +1,12 @@ -from typing import Optional, Union +from __future__ import annotations from .condatools import InCondaPkgCtx from .wheeltools import InWheelCtx def InGenericPkgCtx( - in_path: str, out_path: Optional[str] = None -) -> Union[InWheelCtx, InCondaPkgCtx]: + in_path: str, out_path: str | None = None +) -> InWheelCtx | InCondaPkgCtx: """Factory that returns a InWheelCtx or InCondaPkgCtx context manager depending on the file extension """ diff --git a/src/repairwheel/_vendor/auditwheel/hashfile.py b/src/repairwheel/_vendor/auditwheel/hashfile.py index 96598be..13bcf51 100644 --- a/src/repairwheel/_vendor/auditwheel/hashfile.py +++ b/src/repairwheel/_vendor/auditwheel/hashfile.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import hashlib from typing import BinaryIO diff --git a/src/repairwheel/_vendor/auditwheel/lddtree.py b/src/repairwheel/_vendor/auditwheel/lddtree.py index 6ebfab7..2e7d495 100644 --- a/src/repairwheel/_vendor/auditwheel/lddtree.py +++ b/src/repairwheel/_vendor/auditwheel/lddtree.py @@ -12,13 +12,15 @@ a flat list. """ +from __future__ import annotations + import errno import functools import glob import logging import os from pathlib import Path -from typing import Any, Dict, List, Optional, Tuple +from typing import Any from elftools.elf.elffile import ELFFile @@ -72,13 +74,13 @@ def readlink(path: str, root: str, prefixed: bool = False) -> str: return normpath((root + path) if prefixed else path) -def dedupe(items: List[str]) -> List[str]: +def dedupe(items: list[str]) -> list[str]: """Remove all duplicates from ``items`` (keeping order)""" - seen = {} # type: Dict[str, str] + seen: dict[str, str] = {} return [seen.setdefault(x, x) for x in items if x not in seen] -def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> List[str]: +def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> list[str]: """Parse the colon-delimited list of paths and apply ldso rules to each Note the special handling as dictated by the ldso: @@ -99,7 +101,7 @@ def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> List[str]: ------- list of processed paths """ - ldpaths = [] # type: List[str] + ldpaths: list[str] = [] for ldpath in str_ldpaths.split(":"): if ldpath == "": # The ldso treats "" paths as $PWD. @@ -113,7 +115,7 @@ def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> List[str]: @functools.lru_cache() -def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> List[str]: +def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> list[str]: """Load all the paths from a given ldso config file This should handle comments, whitespace, and "include" statements. @@ -131,7 +133,7 @@ def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> Li ------- list of paths found """ - paths = [] # type: List[str] + paths: list[str] = [] dbg_pfx = "" if _first else " " try: @@ -165,7 +167,7 @@ def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> Li @functools.lru_cache() -def load_ld_paths(root: str = "/", prefix: str = "") -> Dict[str, List[str]]: +def load_ld_paths(root: str = "/", prefix: str = "") -> dict[str, list[str]]: """Load linker paths from common locations This parses the ld.so.conf and LD_LIBRARY_PATH env var. @@ -181,7 +183,7 @@ def load_ld_paths(root: str = "/", prefix: str = "") -> Dict[str, List[str]]: ------- dict containing library paths to search """ - ldpaths = {"conf": [], "env": [], "interp": []} # type: Dict + ldpaths: dict = {"conf": [], "env": [], "interp": []} # Load up $LD_LIBRARY_PATH. env_ldpath = os.environ.get("LD_LIBRARY_PATH") @@ -258,8 +260,8 @@ def compatible_elfs(elf1: ELFFile, elf2: ELFFile) -> bool: def find_lib( - elf: ELFFile, lib: str, ldpaths: List[str], root: str = "/" -) -> Tuple[Optional[str], Optional[str]]: + elf: ELFFile, lib: str, ldpaths: list[str], root: str = "/" +) -> tuple[str | None, str | None]: """Try to locate a ``lib`` that is compatible to ``elf`` in the given ``ldpaths`` @@ -269,7 +271,7 @@ def find_lib( The elf which the library should be compatible with (ELF wise) lib : str The library (basename) to search for - ldpaths : List[str] + ldpaths : list[str] A list of paths to search root : str The root path to resolve symlinks @@ -296,11 +298,11 @@ def lddtree( path: str, root: str = "/", prefix: str = "", - ldpaths: Optional[Dict[str, List[str]]] = None, - display: Optional[str] = None, + ldpaths: dict[str, list[str]] | None = None, + display: str | None = None, _first: bool = True, - _all_libs: Dict = {}, -) -> Dict: + _all_libs: dict = {}, +) -> dict: """Parse the ELF dependency tree of the specified file Parameters @@ -347,7 +349,7 @@ def lddtree( if _first: _all_libs = {} - ret = { + ret: dict[str, Any] = { "interp": None, "path": path if display is None else display, "realpath": path, @@ -355,7 +357,7 @@ def lddtree( "rpath": [], "runpath": [], "libs": _all_libs, - } # type: Dict[str, Any] + } log.debug("lddtree(%s)" % path) @@ -387,9 +389,9 @@ def lddtree( break # Parse the ELF's dynamic tags. - libs = [] # type: List[str] - rpaths = [] # type: List[str] - runpaths = [] # type: List[str] + libs: list[str] = [] + rpaths: list[str] = [] + runpaths: list[str] = [] for segment in elf.iter_segments(): if segment.header.p_type != "PT_DYNAMIC": continue @@ -420,7 +422,7 @@ def lddtree( ret["needed"] = libs # Search for the libs this ELF uses. - all_ldpaths = None # type: Optional[List[str]] + all_ldpaths: list[str] | None = None for lib in libs: if lib in _all_libs: continue diff --git a/src/repairwheel/_vendor/auditwheel/libc.py b/src/repairwheel/_vendor/auditwheel/libc.py index d3f1979..89a6841 100644 --- a/src/repairwheel/_vendor/auditwheel/libc.py +++ b/src/repairwheel/_vendor/auditwheel/libc.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from enum import IntEnum diff --git a/src/repairwheel/_vendor/auditwheel/main.py b/src/repairwheel/_vendor/auditwheel/main.py index 39f3810..51d8f1f 100644 --- a/src/repairwheel/_vendor/auditwheel/main.py +++ b/src/repairwheel/_vendor/auditwheel/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import argparse import logging import os @@ -9,14 +11,12 @@ else: import importlib_metadata as metadata -from typing import Optional - from repairwheel._vendor import auditwheel from . import main_addtag, main_lddtree, main_repair, main_show -def main() -> Optional[int]: +def main() -> int | None: if sys.platform != "linux": print("Error: This tool only supports Linux") return 1 diff --git a/src/repairwheel/_vendor/auditwheel/main_addtag.py b/src/repairwheel/_vendor/auditwheel/main_addtag.py index b77e1ef..271d086 100644 --- a/src/repairwheel/_vendor/auditwheel/main_addtag.py +++ b/src/repairwheel/_vendor/auditwheel/main_addtag.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from os.path import abspath, basename, exists, join diff --git a/src/repairwheel/_vendor/auditwheel/main_lddtree.py b/src/repairwheel/_vendor/auditwheel/main_lddtree.py index ef94857..d8bf9e6 100644 --- a/src/repairwheel/_vendor/auditwheel/main_lddtree.py +++ b/src/repairwheel/_vendor/auditwheel/main_lddtree.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging logger = logging.getLogger(__name__) diff --git a/src/repairwheel/_vendor/auditwheel/main_repair.py b/src/repairwheel/_vendor/auditwheel/main_repair.py index 8c86b96..ce9b58d 100644 --- a/src/repairwheel/_vendor/auditwheel/main_repair.py +++ b/src/repairwheel/_vendor/auditwheel/main_repair.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import argparse import logging from os.path import abspath, basename, exists, isfile diff --git a/src/repairwheel/_vendor/auditwheel/main_show.py b/src/repairwheel/_vendor/auditwheel/main_show.py index a62835e..e3fe9a1 100644 --- a/src/repairwheel/_vendor/auditwheel/main_show.py +++ b/src/repairwheel/_vendor/auditwheel/main_show.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging from collections import OrderedDict diff --git a/src/repairwheel/_vendor/auditwheel/musllinux.py b/src/repairwheel/_vendor/auditwheel/musllinux.py index 761e060..30b4e66 100644 --- a/src/repairwheel/_vendor/auditwheel/musllinux.py +++ b/src/repairwheel/_vendor/auditwheel/musllinux.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import pathlib import re diff --git a/src/repairwheel/_vendor/auditwheel/patcher.py b/src/repairwheel/_vendor/auditwheel/patcher.py index cd6bcd6..a2f1efa 100644 --- a/src/repairwheel/_vendor/auditwheel/patcher.py +++ b/src/repairwheel/_vendor/auditwheel/patcher.py @@ -1,12 +1,13 @@ +from __future__ import annotations + import re from distutils.spawn import find_executable from itertools import chain from subprocess import CalledProcessError, check_call, check_output -from typing import Tuple class ElfPatcher: - def replace_needed(self, file_name: str, *old_new_pairs: Tuple[str, str]) -> None: + def replace_needed(self, file_name: str, *old_new_pairs: tuple[str, str]) -> None: raise NotImplementedError def set_soname(self, file_name: str, new_so_name: str) -> None: @@ -43,7 +44,7 @@ class Patchelf(ElfPatcher): def __init__(self) -> None: _verify_patchelf() - def replace_needed(self, file_name: str, *old_new_pairs: Tuple[str, str]) -> None: + def replace_needed(self, file_name: str, *old_new_pairs: tuple[str, str]) -> None: check_call( [ "patchelf", @@ -58,12 +59,10 @@ def set_soname(self, file_name: str, new_so_name: str) -> None: check_call(["patchelf", "--set-soname", new_so_name, file_name]) def set_rpath(self, file_name: str, rpath: str) -> None: - check_call(["patchelf", "--remove-rpath", file_name]) check_call(["patchelf", "--force-rpath", "--set-rpath", rpath, file_name]) def get_rpath(self, file_name: str) -> str: - return ( check_output(["patchelf", "--print-rpath", file_name]) .decode("utf-8") diff --git a/src/repairwheel/_vendor/auditwheel/policy/__init__.py b/src/repairwheel/_vendor/auditwheel/policy/__init__.py index 9f0cc84..97fd388 100644 --- a/src/repairwheel/_vendor/auditwheel/policy/__init__.py +++ b/src/repairwheel/_vendor/auditwheel/policy/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import logging import platform as _platform_module @@ -5,7 +7,6 @@ from collections import defaultdict from os.path import abspath, dirname, join from pathlib import Path -from typing import Dict, List, Optional, Set from ..libc import Libc, get_libc from ..musllinux import find_musl_libc, get_musl_version @@ -20,10 +21,14 @@ def get_arch_name() -> str: machine = _platform_module.machine() - if machine not in {"x86_64", "i686"}: - return machine - else: + if sys.platform == "darwin" and machine == "arm64": + return "aarch64" + if machine in {"x86_64", "i686"}: return {64: "x86_64", 32: "i686"}[bits] + if machine in {"aarch64", "armv8l"}: + # use armv7l policy for 64-bit arm kernel in 32-bit mode (armv8l) + return {64: "aarch64", 32: "armv7l"}[bits] + return machine _ARCH_NAME = get_arch_name() @@ -31,8 +36,8 @@ def get_arch_name() -> str: def _validate_pep600_compliance(policies) -> None: - symbol_versions: Dict[str, Dict[str, Set[str]]] = {} - lib_whitelist: Set[str] = set() + symbol_versions: dict[str, dict[str, set[str]]] = {} + lib_whitelist: set[str] = set() for policy in sorted(policies, key=lambda x: x["priority"], reverse=True): if policy["name"] == "linux": continue @@ -131,7 +136,7 @@ def _load_policy_schema(): return schema -def get_policy_by_name(name: str) -> Optional[Dict]: +def get_policy_by_name(name: str) -> dict | None: matches = [p for p in _POLICIES if p["name"] == name or name in p["aliases"]] if len(matches) == 0: return None @@ -140,7 +145,7 @@ def get_policy_by_name(name: str) -> Optional[Dict]: return matches[0] -def get_policy_name(priority: int) -> Optional[str]: +def get_policy_name(priority: int) -> str | None: matches = [p["name"] for p in _POLICIES if p["priority"] == priority] if len(matches) == 0: return None @@ -149,12 +154,12 @@ def get_policy_name(priority: int) -> Optional[str]: return matches[0] -def get_priority_by_name(name: str) -> Optional[int]: +def get_priority_by_name(name: str) -> int | None: policy = get_policy_by_name(name) return None if policy is None else policy["priority"] -def get_replace_platforms(name: str) -> List[str]: +def get_replace_platforms(name: str) -> list[str]: """Extract platform tag replacement rules from policy >>> get_replace_platforms('linux_x86_64') diff --git a/src/repairwheel/_vendor/auditwheel/policy/external_references.py b/src/repairwheel/_vendor/auditwheel/policy/external_references.py index cecd594..23afde8 100644 --- a/src/repairwheel/_vendor/auditwheel/policy/external_references.py +++ b/src/repairwheel/_vendor/auditwheel/policy/external_references.py @@ -1,20 +1,22 @@ +from __future__ import annotations + import logging import re -from typing import Any, Dict, Generator, Set +from typing import Any, Generator from ..elfutils import filter_undefined_symbols, is_subdir from . import load_policies log = logging.getLogger(__name__) -LIBPYTHON_RE = re.compile(r"^libpython\d\.\dm?.so(.\d)*$") +LIBPYTHON_RE = re.compile(r"^libpython\d+\.\d+m?.so(.\d)*$") -def lddtree_external_references(lddtree: Dict, wheel_path: str) -> Dict: +def lddtree_external_references(lddtree: dict, wheel_path: str) -> dict: # XXX: Document the lddtree structure, or put it in something # more stable than a big nested dict policies = load_policies() - def filter_libs(libs: Set[str], whitelist: Set[str]) -> Generator[str, None, None]: + def filter_libs(libs: set[str], whitelist: set[str]) -> Generator[str, None, None]: for lib in libs: if "ld-linux" in lib or lib in ["ld64.so.2", "ld64.so.1"]: # always exclude ELF dynamic linker/loader @@ -30,7 +32,7 @@ def filter_libs(libs: Set[str], whitelist: Set[str]) -> Generator[str, None, Non continue yield lib - def get_req_external(libs: Set[str], whitelist: Set[str]) -> Set[str]: + def get_req_external(libs: set[str], whitelist: set[str]) -> set[str]: # get all the required external libraries libs = libs.copy() reqs = set() @@ -42,9 +44,9 @@ def get_req_external(libs: Set[str], whitelist: Set[str]) -> Set[str]: libs.add(dep) return reqs - ret = {} # type: Dict[str, Dict[str, Any]] + ret: dict[str, dict[str, Any]] = {} for p in policies: - needed_external_libs = set() # type: Set[str] + needed_external_libs: set[str] = set() blacklist = {} if not (p["name"] == "linux" and p["priority"] == 0): diff --git a/src/repairwheel/_vendor/auditwheel/policy/versioned_symbols.py b/src/repairwheel/_vendor/auditwheel/policy/versioned_symbols.py index db0c1ab..7d4e0a1 100644 --- a/src/repairwheel/_vendor/auditwheel/policy/versioned_symbols.py +++ b/src/repairwheel/_vendor/auditwheel/policy/versioned_symbols.py @@ -1,14 +1,15 @@ +from __future__ import annotations + import logging -from typing import Dict, List, Set from . import load_policies log = logging.getLogger(__name__) -def versioned_symbols_policy(versioned_symbols: Dict[str, Set[str]]) -> int: +def versioned_symbols_policy(versioned_symbols: dict[str, set[str]]) -> int: def policy_is_satisfied( - policy_name: str, policy_sym_vers: Dict[str, Set[str]] + policy_name: str, policy_sym_vers: dict[str, set[str]] ) -> bool: policy_satisfied = True for name in set(required_vers) & set(policy_sym_vers): @@ -24,12 +25,12 @@ def policy_is_satisfied( policy_satisfied = False return policy_satisfied - required_vers = {} # type: Dict[str, Set[str]] + required_vers: dict[str, set[str]] = {} for symbols in versioned_symbols.values(): for symbol in symbols: sym_name, _, _ = symbol.partition("_") required_vers.setdefault(sym_name, set()).add(symbol) - matching_policies = [] # type: List[int] + matching_policies: list[int] = [] for p in load_policies(): policy_sym_vers = { sym_name: {sym_name + "_" + version for version in versions} diff --git a/src/repairwheel/_vendor/auditwheel/repair.py b/src/repairwheel/_vendor/auditwheel/repair.py index 523e8cb..e1d652a 100644 --- a/src/repairwheel/_vendor/auditwheel/repair.py +++ b/src/repairwheel/_vendor/auditwheel/repair.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import itertools import logging import os @@ -9,7 +11,7 @@ from os.path import abspath, basename, dirname, exists, isabs from os.path import join as pjoin from subprocess import check_call -from typing import Dict, Iterable, List, Optional, Tuple +from typing import Iterable from repairwheel._vendor.auditwheel.patcher import ElfPatcher @@ -32,22 +34,21 @@ def repair_wheel( wheel_path: str, - abis: List[str], + abis: list[str], lib_sdir: str, out_dir: str, update_tags: bool, patcher: ElfPatcher, - exclude: List[str], + exclude: list[str], strip: bool = False, -) -> Optional[str]: - +) -> str | None: external_refs_by_fn = get_wheel_elfdata(wheel_path)[1] # Do not repair a pure wheel, i.e. has no external refs if not external_refs_by_fn: return None - soname_map = {} # type: Dict[str, Tuple[str, str]] + soname_map: dict[str, tuple[str, str]] = {} if not isabs(out_dir): out_dir = abspath(out_dir) @@ -68,10 +69,9 @@ def repair_wheel( # here, fn is a path to a python extension library in # the wheel, and v['libs'] contains its required libs for fn, v in external_refs_by_fn.items(): - ext_libs = v[abis[0]]["libs"] # type: Dict[str, str] - replacements = [] # type: List[Tuple[str, str]] + ext_libs: dict[str, str] = v[abis[0]]["libs"] + replacements: list[tuple[str, str]] = [] for soname, src_path in ext_libs.items(): - if soname in exclude: logger.info(f"Excluding {soname}") continue @@ -126,7 +126,7 @@ def strip_symbols(libraries: Iterable[str]) -> None: check_call(["strip", "-s", lib]) -def copylib(src_path: str, dest_dir: str, patcher: ElfPatcher) -> Tuple[str, str]: +def copylib(src_path: str, dest_dir: str, patcher: ElfPatcher) -> tuple[str, str]: """Graft a shared library from the system into the wheel and update the relevant links. diff --git a/src/repairwheel/_vendor/auditwheel/tmpdirs.py b/src/repairwheel/_vendor/auditwheel/tmpdirs.py index 942b15f..54c397d 100644 --- a/src/repairwheel/_vendor/auditwheel/tmpdirs.py +++ b/src/repairwheel/_vendor/auditwheel/tmpdirs.py @@ -1,9 +1,10 @@ """ Contexts for *with* statement providing temporary directories """ +from __future__ import annotations + import os from tempfile import TemporaryDirectory from types import TracebackType -from typing import Optional, Type class InTemporaryDirectory: @@ -37,9 +38,9 @@ def __enter__(self) -> str: def __exit__( self, - exc: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], + exc: type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, ) -> None: os.chdir(self._pwd) return self._tmpdir.__exit__(exc, value, tb) @@ -69,7 +70,7 @@ class InGivenDirectory: again. """ - def __init__(self, path: Optional[str] = None) -> None: + def __init__(self, path: str | None = None) -> None: """Initialize directory context manager Parameters @@ -91,8 +92,8 @@ def __enter__(self) -> str: def __exit__( self, - exc: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], + exc: type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, ) -> None: os.chdir(self._pwd) diff --git a/src/repairwheel/_vendor/auditwheel/tools.py b/src/repairwheel/_vendor/auditwheel/tools.py index bce72f2..63b3280 100644 --- a/src/repairwheel/_vendor/auditwheel/tools.py +++ b/src/repairwheel/_vendor/auditwheel/tools.py @@ -1,12 +1,14 @@ +from __future__ import annotations + import argparse import os import subprocess import zipfile from datetime import datetime, timezone -from typing import Any, Iterable, List, Optional +from typing import Any, Iterable -def unique_by_index(sequence: Iterable[Any]) -> List[Any]: +def unique_by_index(sequence: Iterable[Any]) -> list[Any]: """unique elements in `sequence` in the order in which they occur Parameters @@ -50,7 +52,7 @@ def zip2dir(zip_fname: str, out_dir: str) -> None: os.chmod(extracted_path, attr) -def dir2zip(in_dir: str, zip_fname: str, date_time: Optional[datetime] = None) -> None: +def dir2zip(in_dir: str, zip_fname: str, date_time: datetime | None = None) -> None: """Make a zip file `zip_fname` with contents of directory `in_dir` The recorded filenames are relative to `in_dir`, so doing a standard zip diff --git a/src/repairwheel/_vendor/auditwheel/wheel_abi.py b/src/repairwheel/_vendor/auditwheel/wheel_abi.py index de95479..9dcde77 100644 --- a/src/repairwheel/_vendor/auditwheel/wheel_abi.py +++ b/src/repairwheel/_vendor/auditwheel/wheel_abi.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import functools import itertools import json @@ -7,7 +9,6 @@ from collections.abc import Mapping from copy import deepcopy from os.path import basename -from typing import Dict, Set from .elfutils import ( elf_file_filter, @@ -62,7 +63,7 @@ def get_wheel_elfdata(wheel_fn: str): full_elftree = {} nonpy_elftree = {} full_external_refs = {} - versioned_symbols = defaultdict(lambda: set()) # type: Dict[str, Set[str]] + versioned_symbols: dict[str, set[str]] = defaultdict(lambda: set()) uses_ucs2_symbols = False uses_PyFPE_jbuf = False @@ -165,14 +166,14 @@ def get_wheel_elfdata(wheel_fn: str): ) -def get_external_libs(external_refs) -> Dict[str, str]: +def get_external_libs(external_refs) -> dict[str, str]: """Get external library dependencies for all policies excluding the default linux policy :param external_refs: external references for all policies :return: {realpath: soname} e.g. {'/path/to/external_ref.so.1.2.3': 'external_ref.so.1'} """ - result: Dict[str, str] = {} + result: dict[str, str] = {} for policy in external_refs.values(): # linux tag (priority 0) has no white-list, do not analyze it if policy["priority"] == 0: diff --git a/src/repairwheel/_vendor/auditwheel/wheeltools.py b/src/repairwheel/_vendor/auditwheel/wheeltools.py index af99f94..ab09278 100644 --- a/src/repairwheel/_vendor/auditwheel/wheeltools.py +++ b/src/repairwheel/_vendor/auditwheel/wheeltools.py @@ -3,6 +3,8 @@ Tools that aren't specific to delocation """ +from __future__ import annotations + import csv import glob import hashlib @@ -17,7 +19,7 @@ from os.path import sep as psep from os.path import splitext from types import TracebackType -from typing import Generator, Iterable, List, Optional, Type +from typing import Generator, Iterable from ._vendor.wheel.pkginfo import read_pkg_info, write_pkg_info from ._vendor.wheel.wheelfile import WHEEL_INFO_RE @@ -101,7 +103,7 @@ class InWheel(InTemporaryDirectory): pack stuff up for you. """ - def __init__(self, in_wheel: str, out_wheel: Optional[str] = None) -> None: + def __init__(self, in_wheel: str, out_wheel: str | None = None) -> None: """Initialize in-wheel context manager Parameters @@ -122,9 +124,9 @@ def __enter__(self) -> str: def __exit__( self, - exc: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], + exc: type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, ) -> None: if self.out_wheel is not None: rewrite_record(self.name) @@ -152,7 +154,7 @@ class InWheelCtx(InWheel): ``wheel_path``. """ - def __init__(self, in_wheel: str, out_wheel: Optional[str] = None) -> None: + def __init__(self, in_wheel: str, out_wheel: str | None = None) -> None: """Init in-wheel context manager returning self from enter Parameters @@ -186,7 +188,7 @@ def iter_files(self) -> Generator[str, None, None]: def add_platforms( - wheel_ctx: InWheelCtx, platforms: List[str], remove_platforms: Iterable[str] = () + wheel_ctx: InWheelCtx, platforms: list[str], remove_platforms: Iterable[str] = () ) -> str: """Add platform tags `platforms` to a wheel diff --git a/src/repairwheel/_vendor/vendor.txt b/src/repairwheel/_vendor/vendor.txt index 7a191fd..57efbb8 100644 --- a/src/repairwheel/_vendor/vendor.txt +++ b/src/repairwheel/_vendor/vendor.txt @@ -1,2 +1,2 @@ -auditwheel==5.3.0 +auditwheel==5.4.0 delocate==0.10.4 diff --git a/tools/vendoring/patches/auditwheel.patch b/tools/vendoring/patches/auditwheel.patch index 01f41b4..416b0f8 100644 --- a/tools/vendoring/patches/auditwheel.patch +++ b/tools/vendoring/patches/auditwheel.patch @@ -2,15 +2,15 @@ diff --git a/src/repairwheel/_vendor/auditwheel/elfutils.py b/src/repairwheel/_v index 33527c9..a319350 100644 --- a/src/repairwheel/_vendor/auditwheel/elfutils.py +++ b/src/repairwheel/_vendor/auditwheel/elfutils.py -@@ -1,5 +1,5 @@ +@@ -3,5 +3,5 @@ -import os -from os.path import basename, realpath, relpath +from os.path import basename +from pathlib import Path - from typing import Dict, Iterator, List, Optional, Set, Tuple + from typing import Iterator from elftools.common.exceptions import ELFError -@@ -130,12 +130,12 @@ def is_subdir(path: str, directory: str) -> bool: +@@ -131,12 +131,12 @@ def is_subdir(path: str, directory: str) -> bool: if path is None: return False