Skip to content

Commit

Permalink
Bundle auditwheel==5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jvolkman committed May 5, 2023
1 parent 21c6a1e commit a160f81
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 107 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import sys

from .main import main
Expand Down
7 changes: 4 additions & 3 deletions src/repairwheel/_vendor/auditwheel/condatools.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand Down
24 changes: 12 additions & 12 deletions src/repairwheel/_vendor/auditwheel/elfutils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
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

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)
Expand All @@ -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
"""
Expand All @@ -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:
Expand All @@ -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


Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/repairwheel/_vendor/auditwheel/error.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class AuditwheelException(Exception):
pass

Expand Down
6 changes: 3 additions & 3 deletions src/repairwheel/_vendor/auditwheel/genericpkgctx.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/hashfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import hashlib
from typing import BinaryIO

Expand Down
46 changes: 24 additions & 22 deletions src/repairwheel/_vendor/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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")
Expand Down Expand Up @@ -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``
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -347,15 +349,15 @@ def lddtree(
if _first:
_all_libs = {}

ret = {
ret: dict[str, Any] = {
"interp": None,
"path": path if display is None else display,
"realpath": path,
"needed": [],
"rpath": [],
"runpath": [],
"libs": _all_libs,
} # type: Dict[str, Any]
}

log.debug("lddtree(%s)" % path)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/libc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from enum import IntEnum

Expand Down
6 changes: 3 additions & 3 deletions src/repairwheel/_vendor/auditwheel/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import logging
import os
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/main_addtag.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from os.path import abspath, basename, exists, join

Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/main_lddtree.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging

logger = logging.getLogger(__name__)
Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/main_repair.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import logging
from os.path import abspath, basename, exists, isfile
Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/main_show.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from collections import OrderedDict

Expand Down
2 changes: 2 additions & 0 deletions src/repairwheel/_vendor/auditwheel/musllinux.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import pathlib
import re
Expand Down
Loading

0 comments on commit a160f81

Please sign in to comment.