From ef0df29c57f89739670acce1f94fa2493db6cc8a Mon Sep 17 00:00:00 2001 From: Jeremy Volkman Date: Thu, 14 Dec 2023 15:43:26 -0800 Subject: [PATCH] Bump delocate version --- src/repairwheel/_vendor/delocate/_version.py | 4 +- .../_vendor/delocate/cmd/common.py | 158 ++++++++------- .../_vendor/delocate/cmd/delocate_addplat.py | 190 ++++++++---------- .../_vendor/delocate/cmd/delocate_fuse.py | 51 ++--- .../_vendor/delocate/cmd/delocate_listdeps.py | 65 +++--- .../_vendor/delocate/cmd/delocate_patch.py | 67 +++--- .../_vendor/delocate/cmd/delocate_path.py | 63 +++--- .../_vendor/delocate/cmd/delocate_wheel.py | 131 ++++++------ .../_vendor/delocate/delocating.py | 5 +- src/repairwheel/_vendor/delocate/fuse.py | 3 +- src/repairwheel/_vendor/delocate/libsana.py | 5 +- .../_vendor/delocate/wheeltools.py | 4 +- src/repairwheel/_vendor/vendor.txt | 2 +- tools/vendoring/patches/delocate.chmod.patch | 22 -- tools/vendoring/patches/delocate.patch | 170 ++++++++-------- 15 files changed, 441 insertions(+), 499 deletions(-) delete mode 100644 tools/vendoring/patches/delocate.chmod.patch diff --git a/src/repairwheel/_vendor/delocate/_version.py b/src/repairwheel/_vendor/delocate/_version.py index ea1eeb0..5163f0b 100644 --- a/src/repairwheel/_vendor/delocate/_version.py +++ b/src/repairwheel/_vendor/delocate/_version.py @@ -12,5 +12,5 @@ __version_tuple__: VERSION_TUPLE version_tuple: VERSION_TUPLE -__version__ = version = '0.10.6' -__version_tuple__ = version_tuple = (0, 10, 6) +__version__ = version = '0.10.7' +__version_tuple__ = version_tuple = (0, 10, 7) diff --git a/src/repairwheel/_vendor/delocate/cmd/common.py b/src/repairwheel/_vendor/delocate/cmd/common.py index 24959f6..f0c26a9 100644 --- a/src/repairwheel/_vendor/delocate/cmd/common.py +++ b/src/repairwheel/_vendor/delocate/cmd/common.py @@ -4,91 +4,84 @@ """ from __future__ import annotations +import glob import logging import os import sys -from optparse import Option, OptionParser, Values -from typing import Callable, List +from argparse import ArgumentParser, Namespace +from pathlib import Path +from typing import Callable, Iterable, Iterator, List -from ..delocating import filter_system_libs from typing_extensions import Literal, TypedDict -logger = logging.getLogger(__name__) - +from .. import __version__ +from ..delocating import filter_system_libs -def verbosity_args(parser: OptionParser) -> None: - """Logging arguments shared by all commands.""" - parser.add_options( - [ - Option( - "-v", - "--verbose", - action="count", - help=( - "Show a more verbose report of progress and failure." - " Additional flags show even more info, up to -vv." - ), - default=0, - ), - ] - ) +logger = logging.getLogger(__name__) -def verbosity_config(opts: Values) -> None: +common_parser = ArgumentParser(add_help=False) +"""Version and logging arguments shared by all commands.""" + +common_parser.add_argument( + "--version", action="version", version=f"%(prog)s {__version__}" +) +common_parser.add_argument( + "-v", + "--verbose", + action="count", + help="Show a more verbose report of progress and failure," + " additional flags show even more info, up to -vv", + default=0, +) + + +delocate_parser = ArgumentParser(add_help=False) +"""Arguments shared by delocate-path and delocate-wheel commands.""" + +delocate_parser.add_argument( + "-d", + "--dylibs-only", + action="store_true", + help="Only analyze files with known dynamic library extensions", +) +delocate_parser.add_argument( + "-e", + "--exclude", + action="append", + default=[], + type=str, + help="Exclude any libraries where path includes the given string", +) +delocate_parser.add_argument( + "--executable-path", + action="store", + type=str, + default=os.path.dirname(sys.executable), + help="The path used to resolve @executable_path in dependencies", +) +delocate_parser.add_argument( + "--ignore-missing-dependencies", + action="store_true", + help="Skip dependencies which couldn't be found and delocate" + " as much as possible", +) +delocate_parser.add_argument( + "--sanitize-rpaths", + action="store_true", + help="Remove absolute and relative rpaths from binaries", +) + + +def verbosity_config(args: Namespace) -> None: """Configure logging from parsed verbosity arguments.""" logging.basicConfig( level={0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG}.get( - opts.verbose, logging.DEBUG + args.verbose, logging.DEBUG ) ) -def delocate_args(parser: OptionParser): - """Arguments shared by delocate-path and delocate-wheel commands.""" - parser.add_options( - [ - Option( - "-d", - "--dylibs-only", - action="store_true", - help="Only analyze files with known dynamic library extensions", - ), - Option( - "-e", - "--exclude", - action="append", - default=[], - type="string", - help=( - "Exclude any libraries where path includes the given string" - ), - ), - Option( - "--executable-path", - action="store", - type="string", - default=os.path.dirname(sys.executable), - help=( - "The path used to resolve @executable_path in dependencies" - ), - ), - Option( - "--ignore-missing-dependencies", - action="store_true", - help=( - "Skip dependencies which couldn't be found and delocate " - "as much as possible" - ), - ), - Option( - "--sanitize-rpaths", - action="store_true", - help="Remove absolute and relative rpaths from binaries", - ), - ] - ) - - class DelocateArgs(TypedDict): """Common kwargs for delocate_path and delocate_wheel.""" @@ -99,10 +92,10 @@ class DelocateArgs(TypedDict): sanitize_rpaths: bool -def delocate_values(opts: Values) -> DelocateArgs: +def delocate_values(args: Namespace) -> DelocateArgs: """Return the common kwargs for delocate_path and delocate_wheel.""" - exclude_files: List[str] = opts.exclude + exclude_files: List[str] = args.exclude def copy_filter_exclude(name: str) -> bool: """Returns False if name is excluded, uses normal rules otherwise.""" @@ -118,8 +111,23 @@ def copy_filter_exclude(name: str) -> bool: return { "copy_filt_func": copy_filter_exclude, - "executable_path": opts.executable_path, - "lib_filt_func": "dylibs-only" if opts.dylibs_only else None, - "ignore_missing": opts.ignore_missing_dependencies, - "sanitize_rpaths": opts.sanitize_rpaths, + "executable_path": args.executable_path, + "lib_filt_func": "dylibs-only" if args.dylibs_only else None, + "ignore_missing": args.ignore_missing_dependencies, + "sanitize_rpaths": args.sanitize_rpaths, } + + +def glob_paths(paths: Iterable[str]) -> Iterator[str]: + """Iterate over the expanded paths of potential glob paths. + + Does not try to glob paths which match existing files. + """ + for path in paths: + if Path(path).exists(): + yield path # Don't try to expand paths when their target exists + continue + expanded_paths = glob.glob(path) + if not expanded_paths: + raise FileNotFoundError(path) + yield from expanded_paths diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py b/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py index e6c62f8..df0fef0 100644 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py @@ -1,4 +1,4 @@ -#!python +#!/usr/bin/env python3 """ Add platform tags to wheel filename(s) and WHEEL file in wheel Example: @@ -17,122 +17,102 @@ from __future__ import absolute_import, division, print_function import os -import sys -from optparse import Option, OptionParser -from os.path import expanduser +from argparse import ArgumentParser +from os.path import expanduser, realpath from os.path import join as exists -from os.path import realpath -from .. import __version__ -from ..cmd.common import verbosity_args, verbosity_config +from ..cmd.common import common_parser, glob_paths, verbosity_config from ..wheeltools import WheelToolsError, add_platforms +parser = ArgumentParser(description=__doc__, parents=[common_parser]) +parser.add_argument( + "wheels", + nargs="+", + metavar="WHEEL", + type=str, + help="Wheel to modify", +) +parser.add_argument( + "-p", + "--plat-tag", + metavar="PLATFORM_TAG", + action="append", + type=str, + help="Platform tag to add (e.g. macosx_10_9_intel)" + " (can be specified multiple times)", +) +parser.add_argument( + "-x", + "--osx-ver", + metavar="OSX_VERSION", + action="append", + type=str, + help="Alternative method to specify platform tags, by giving " + 'OSX version numbers - e.g. "10_10" results in adding platform ' + 'tags "macosx_10_10_intel, "macosx_10_10_x86_64") (can be ' + "specified multiple times)", +) +parser.add_argument( + "-w", + "--wheel-dir", + action="store", + type=str, + help=( + "Directory to store delocated wheels (default is to " "overwrite input)" + ), +) +parser.add_argument( + "-c", + "--clobber", + action="store_true", + help="Overwrite pre-existing wheels", +) +parser.add_argument( + "-r", + "--rm-orig", + action="store_true", + help="Remove unmodified wheel if wheel is rewritten", +) +parser.add_argument( + "-k", + "--skip-errors", + action="store_true", + help="Skip wheels that raise errors (e.g. pure wheels)", +) +parser.add_argument( + "-d", + "--dual-arch-type", + metavar="ARCHITECTURE", + action="store", + type=str, + default="intel", + help="Dual architecture wheel type; one of 'intel', 'universal2';" + " (default %(default)s)", +) + def main() -> None: - parser = OptionParser( - usage="%s WHEEL_FILENAME\n\n" % sys.argv[0] + __doc__, - version="%prog " + __version__, - ) - verbosity_args(parser) - parser.add_option( - Option( - "-p", - "--plat-tag", - action="append", - type="string", - help=( - "Platform tag to add (e.g. macosx_10_9_intel) (can be " - "specified multiple times)" - ), - ) - ) - parser.add_option( - Option( - "-x", - "--osx-ver", - action="append", - type="string", - help=( - "Alternative method to specify platform tags, by giving " - 'OSX version numbers - e.g. "10_10" results in adding platform ' - 'tags "macosx_10_10_intel, "macosx_10_10_x86_64") (can be ' - "specified multiple times)" - ), - ) - ) - parser.add_option( - Option( - "-w", - "--wheel-dir", - action="store", - type="string", - help=( - "Directory to store delocated wheels (default is to " - "overwrite input)" - ), - ) - ) - parser.add_option( - Option( - "-c", - "--clobber", - action="store_true", - help="Overwrite pre-existing wheels", - ) - ) - parser.add_option( - Option( - "-r", - "--rm-orig", - action="store_true", - help="Remove unmodified wheel if wheel is rewritten", - ) - ) - parser.add_option( - Option( - "-k", - "--skip-errors", - action="store_true", - help="Skip wheels that raise errors (e.g. pure wheels)", - ) - ) - parser.add_option( - Option( - "-d", - "--dual-arch-type", - action="store", - type="string", - default="intel", - help=( - "Dual architecture wheel type; " - "one of 'intel', 'universal2'; " - "(default 'intel')" - ), - ) - ) - (opts, wheels) = parser.parse_args() - verbosity_config(opts) - if len(wheels) < 1: - parser.print_help() - sys.exit(1) + args = parser.parse_args() + verbosity_config(args) + wheels = list(glob_paths(args.wheels)) multi = len(wheels) > 1 - if opts.wheel_dir: - wheel_dir = expanduser(opts.wheel_dir) + if args.wheel_dir: + wheel_dir = expanduser(args.wheel_dir) if not exists(wheel_dir): os.makedirs(wheel_dir) else: wheel_dir = None - plat_tags = [] if opts.plat_tag is None else opts.plat_tag - if opts.osx_ver is not None: - for ver in opts.osx_ver: + plat_tags = [] if args.plat_tag is None else args.plat_tag + if args.osx_ver is not None: + for ver in args.osx_ver: plat_tags += [ - "macosx_{0}_{1}".format(ver, opts.dual_arch_type), + "macosx_{0}_{1}".format(ver, args.dual_arch_type), "macosx_{0}_x86_64".format(ver), ] if len(plat_tags) == 0: raise RuntimeError("Need at least one --osx-ver or --plat-tag") for wheel in wheels: - if multi or opts.verbose: + if multi or args.verbose: print( "Setting platform tags {0} for wheel {1}".format( ",".join(plat_tags), wheel @@ -140,14 +120,14 @@ def main() -> None: ) try: fname = add_platforms( - wheel, plat_tags, wheel_dir, clobber=opts.clobber + wheel, plat_tags, wheel_dir, clobber=args.clobber ) except WheelToolsError as e: - if opts.skip_errors: + if args.skip_errors: print("Cannot modify {0} because {1}".format(wheel, e)) continue raise - if opts.verbose: + if args.verbose: if fname is None: print( "{0} already has tags {1}".format( @@ -157,12 +137,12 @@ def main() -> None: else: print("Wrote {0}".format(fname)) if ( - opts.rm_orig + args.rm_orig and fname is not None and realpath(fname) != realpath(wheel) ): os.unlink(wheel) - if opts.verbose: + if args.verbose: print("Deleted old wheel " + wheel) diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py b/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py index c5fc5f2..e6025cc 100644 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py @@ -1,4 +1,4 @@ -#!python +#!/usr/bin/env python3 """ Fuse two (probably delocated) wheels Overwrites the first wheel in-place by default @@ -6,44 +6,35 @@ # vim: ft=python from __future__ import absolute_import, division, print_function -import sys -from optparse import Option, OptionParser +from argparse import ArgumentParser from os.path import abspath, basename, expanduser from os.path import join as pjoin -from .. import __version__ -from ..cmd.common import verbosity_args, verbosity_config +from ..cmd.common import common_parser, verbosity_config from ..fuse import fuse_wheels +parser = ArgumentParser(description=__doc__, parents=[common_parser]) +parser.add_argument( + "wheels", nargs=2, metavar="WHEEL", type=str, help="Wheels to fuse" +) +parser.add_argument( + "-w", + "--wheel-dir", + action="store", + type=str, + help="Directory to store delocated wheels" + " (default is to overwrite 1st WHEEL input with 2nd)", +) + def main() -> None: - parser = OptionParser( - usage="%s WHEEL1 WHEEL2\n\n" % sys.argv[0] + __doc__, - version="%prog " + __version__, - ) - verbosity_args(parser) - parser.add_option( - Option( - "-w", - "--wheel-dir", - action="store", - type="string", - help=( - "Directory to store delocated wheels (default is to " - "overwrite WHEEL1 input)" - ), - ) - ) - (opts, wheels) = parser.parse_args() - verbosity_config(opts) - if len(wheels) != 2: - parser.print_help() - sys.exit(1) - wheel1, wheel2 = [abspath(expanduser(wheel)) for wheel in wheels] - if opts.wheel_dir is None: + args = parser.parse_args() + verbosity_config(args) + wheel1, wheel2 = [abspath(expanduser(wheel)) for wheel in args.wheels] + if args.wheel_dir is None: out_wheel = wheel1 else: - out_wheel = pjoin(abspath(expanduser(opts.wheel_dir)), basename(wheel1)) + out_wheel = pjoin(abspath(expanduser(args.wheel_dir)), basename(wheel1)) fuse_wheels(wheel1, wheel2, out_wheel) diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py b/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py index 6a9b192..558adc4 100644 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py @@ -1,49 +1,46 @@ -#!python +#!/usr/bin/env python3 """ List library dependencies for libraries in path or wheel """ # vim: ft=python from __future__ import absolute_import, division, print_function -import sys -from optparse import Option, OptionParser +from argparse import ArgumentParser from os import getcwd from os.path import isdir, realpath from os.path import sep as psep -from .. import __version__, wheel_libs -from ..cmd.common import verbosity_args, verbosity_config +from .. import wheel_libs +from ..cmd.common import common_parser, glob_paths, verbosity_config from ..delocating import filter_system_libs from ..libsana import stripped_lib_dict, tree_libs_from_directory +parser = ArgumentParser(description=__doc__, parents=[common_parser]) +parser.add_argument( + "paths", + nargs="+", + metavar="WHEEL_OR_PATH_TO_ANALYZE", + type=str, + help="Wheel or directory to check for libraries," + " directories are checked recursively", +) +parser.add_argument( + "-a", + "--all", + action="store_true", + help="Show all dependencies, including system libs", +) +parser.add_argument( + "-d", + "--depending", + action="store_true", + help="Show libraries depending on dependencies", +) -def main() -> None: - parser = OptionParser( - usage="%s WHEEL_OR_PATH_TO_ANALYZE\n\n" % sys.argv[0] + __doc__, - version="%prog " + __version__, - ) - verbosity_args(parser) - parser.add_options( - [ - Option( - "-a", - "--all", - action="store_true", - help="Show all dependencies, including system libs", - ), - Option( - "-d", - "--depending", - action="store_true", - help="Show libraries depending on dependencies", - ), - ] - ) - (opts, paths) = parser.parse_args() - verbosity_config(opts) - if len(paths) < 1: - parser.print_help() - sys.exit(1) +def main() -> None: + args = parser.parse_args() + verbosity_config(args) + paths = list(glob_paths(args.paths)) multi = len(paths) > 1 for path in paths: if multi: @@ -57,9 +54,9 @@ def main() -> None: else: lib_dict = wheel_libs(path, ignore_missing=True) keys = sorted(lib_dict) - if not opts.all: + if not args.all: keys = [key for key in keys if filter_system_libs(key)] - if not opts.depending: + if not args.depending: if len(keys): print(indent + ("\n" + indent).join(keys)) continue diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py b/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py index 003d459..3ea52e0 100644 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py @@ -1,4 +1,4 @@ -#!python +#!/usr/bin/env python3 """ Apply patch to tree stored in wheel Overwrites the wheel in-place by default @@ -7,54 +7,47 @@ from __future__ import absolute_import, division, print_function import os -import sys -from optparse import Option, OptionParser +from argparse import ArgumentParser from os.path import basename, exists, expanduser from os.path import join as pjoin -from .. import __version__, patch_wheel -from ..cmd.common import verbosity_args, verbosity_config +from .. import patch_wheel +from ..cmd.common import common_parser, verbosity_config + +parser = ArgumentParser(description=__doc__, parents=[common_parser]) +parser.add_argument( + "wheel", metavar="WHEEL", type=str, help="Wheel file to modify" +) +parser.add_argument( + "patch_fname", metavar="PATCH", type=str, help="Patch file to apply" +) +parser.add_argument( + "-w", + "--wheel-dir", + action="store", + type=str, + help="Directory to store patched wheel (default is to overwrite input)", +) def main() -> None: - parser = OptionParser( - usage="%s WHEEL_FILENAME PATCH_FNAME\n\n" % sys.argv[0] + __doc__, - version="%prog " + __version__, - ) - verbosity_args(parser) - parser.add_option( - Option( - "-w", - "--wheel-dir", - action="store", - type="string", - help=( - "Directory to store patched wheel (default is to " - "overwrite input)" - ), - ) - ) - (opts, args) = parser.parse_args() - verbosity_config(opts) - if len(args) != 2: - parser.print_help() - sys.exit(1) - wheel, patch_fname = args - if opts.wheel_dir: - wheel_dir = expanduser(opts.wheel_dir) + args = parser.parse_args() + verbosity_config(args) + if args.wheel_dir: + wheel_dir = expanduser(args.wheel_dir) if not exists(wheel_dir): os.makedirs(wheel_dir) else: wheel_dir = None - if opts.verbose: - print("Patching: {0} with {1}".format(wheel, patch_fname)) + if args.verbose: + print("Patching: {0} with {1}".format(args.wheel, args.patch_fname)) if wheel_dir: - out_wheel = pjoin(wheel_dir, basename(wheel)) + out_wheel = pjoin(wheel_dir, basename(args.wheel)) else: - out_wheel = wheel - patch_wheel(wheel, patch_fname, out_wheel) - if opts.verbose: - print("Patched wheel {0} to {1}:".format(wheel, out_wheel)) + out_wheel = args.wheel + patch_wheel(args.wheel, args.patch_fname, out_wheel) + if args.verbose: + print("Patched wheel {0} to {1}:".format(args.wheel, out_wheel)) if __name__ == "__main__": diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_path.py b/src/repairwheel/_vendor/delocate/cmd/delocate_path.py index 4ea9d90..8e303ea 100644 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_path.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_path.py @@ -1,58 +1,55 @@ -#!python +#!/usr/bin/env python3 """ Copy, relink library dependencies for libraries in path """ # vim: ft=python from __future__ import absolute_import, division, print_function import os -import sys -from optparse import Option, OptionParser +from argparse import ArgumentParser -from .. import __version__, delocate_path +from .. import delocate_path from ..cmd.common import ( - delocate_args, + common_parser, + delocate_parser, delocate_values, - verbosity_args, + glob_paths, verbosity_config, ) +parser = ArgumentParser( + description=__doc__, parents=[common_parser, delocate_parser] +) +parser.add_argument( + "paths", + nargs="+", + metavar="PATH", + type=str, + help="Folders to be analyzed and delocated", +) +parser.add_argument( + "-L", + "--lib-path", + action="store", + default=".dylibs", + type=str, + help="Output subdirectory path to copy library dependencies", +) -def main() -> None: - parser = OptionParser( - usage="%s PATH_TO_ANALYZE\n\n" % sys.argv[0] + __doc__, - version="%prog " + __version__, - ) - verbosity_args(parser) - delocate_args(parser) - parser.add_options( - [ - Option( - "-L", - "--lib-path", - action="store", - type="string", - help="Output subdirectory path to copy library dependencies", - ), - ] - ) - (opts, paths) = parser.parse_args() - verbosity_config(opts) - if len(paths) < 1: - parser.print_help() - sys.exit(1) - if opts.lib_path is None: - opts.lib_path = ".dylibs" +def main() -> None: + args = parser.parse_args() + verbosity_config(args) + paths = list(glob_paths(args.paths)) multi = len(paths) > 1 for path in paths: if multi: print(path) # evaluate paths relative to the path we are working on - lib_path = os.path.join(path, opts.lib_path) + lib_path = os.path.join(path, args.lib_path) delocate_path( path, lib_path, - **delocate_values(opts), + **delocate_values(args), ) diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py b/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py index cd15864..e28aac3 100644 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py @@ -1,94 +1,89 @@ -#!python +#!/usr/bin/env python3 """ Copy, relink library dependencies for wheel Overwrites the wheel in-place by default """ # vim: ft=python -from __future__ import absolute_import, division, print_function +from __future__ import annotations import os -import sys -from optparse import Option, OptionParser +from argparse import ArgumentParser from os.path import basename, exists, expanduser from os.path import join as pjoin from typing import List, Optional, Text -from .. import __version__, delocate_wheel +from .. import delocate_wheel from ..cmd.common import ( - delocate_args, + common_parser, + delocate_parser, delocate_values, - verbosity_args, + glob_paths, verbosity_config, ) +parser = ArgumentParser( + description=__doc__, parents=[common_parser, delocate_parser] +) +parser.add_argument( + "wheels", + nargs="+", + metavar="WHEEL", + type=str, + help="The wheel files to be delocated", +) +parser.add_argument( + "-L", + "--lib-sdir", + action="store", + type=str, + default=".dylibs", + help="Subdirectory in packages to store copied libraries", +) +parser.add_argument( + "-w", + "--wheel-dir", + action="store", + type=str, + help="Directory to store delocated wheels (default is to overwrite input)", +) +parser.add_argument( + "-k", + "--check-archs", + action="store_true", + help="Check architectures of depended libraries", +) +parser.add_argument( + "--require-archs", + metavar="ARCHITECTURES", + action="store", + type=str, + help="Architectures that all wheel libraries should have" + " (from 'intel', 'i386', 'x86_64', 'i386,x86_64', 'universal2'," + " 'x86_64,arm64')", +) + def main() -> None: - parser = OptionParser( - usage="%s WHEEL_FILENAME\n\n" % sys.argv[0] + __doc__, - version="%prog " + __version__, - ) - verbosity_args(parser) - delocate_args(parser) - parser.add_options( - [ - Option( - "-L", - "--lib-sdir", - action="store", - type="string", - default=".dylibs", - help="Subdirectory in packages to store copied libraries", - ), - Option( - "-w", - "--wheel-dir", - action="store", - type="string", - help=( - "Directory to store delocated wheels (default is to " - "overwrite input)" - ), - ), - Option( - "-k", - "--check-archs", - action="store_true", - help="Check architectures of depended libraries", - ), - Option( - "--require-archs", - action="store", - type="string", - help=( - "Architectures that all wheel libraries should " - "have (from 'intel', 'i386', 'x86_64', 'i386,x86_64'" - "'universal2', 'x86_64,arm64')" - ), - ), - ] - ) - (opts, wheels) = parser.parse_args() - verbosity_config(opts) - if len(wheels) < 1: - parser.print_help() - sys.exit(1) + args = parser.parse_args() + verbosity_config(args) + wheels = list(glob_paths(args.wheels)) multi = len(wheels) > 1 - if opts.wheel_dir: - wheel_dir = expanduser(opts.wheel_dir) + if args.wheel_dir: + wheel_dir = expanduser(args.wheel_dir) if not exists(wheel_dir): os.makedirs(wheel_dir) else: wheel_dir = None require_archs: Optional[List[Text]] = None - if opts.require_archs is None: - require_archs = [] if opts.check_archs else None - elif "," in opts.require_archs: - require_archs = [s.strip() for s in opts.require_archs.split(",")] + if args.require_archs is None: + require_archs = [] if args.check_archs else None + elif "," in args.require_archs: + require_archs = [s.strip() for s in args.require_archs.split(",")] else: - require_archs = opts.require_archs + require_archs = args.require_archs for wheel in wheels: - if multi or opts.verbose: + if multi or args.verbose: print("Fixing: " + wheel) if wheel_dir: out_wheel = pjoin(wheel_dir, basename(wheel)) @@ -97,12 +92,12 @@ def main() -> None: copied = delocate_wheel( wheel, out_wheel, - lib_sdir=opts.lib_sdir, + lib_sdir=args.lib_sdir, require_archs=require_archs, - **delocate_values(opts), + **delocate_values(args), ) - if opts.verbose and len(copied): - print("Copied to package {0} directory:".format(opts.lib_sdir)) + if args.verbose and len(copied): + print("Copied to package {0} directory:".format(args.lib_sdir)) copy_lines = [" " + name for name in sorted(copied)] print("\n".join(copy_lines)) diff --git a/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vendor/delocate/delocating.py index 02469ef..a9cf8f2 100644 --- a/src/repairwheel/_vendor/delocate/delocating.py +++ b/src/repairwheel/_vendor/delocate/delocating.py @@ -9,9 +9,8 @@ import shutil import stat import warnings -from os.path import abspath, basename, dirname, exists +from os.path import abspath, basename, dirname, exists, realpath, relpath from os.path import join as pjoin -from os.path import realpath, relpath from pathlib import Path from subprocess import PIPE, Popen from typing import ( @@ -544,7 +543,7 @@ def _decide_dylib_bundle_directory( """ package_dirs = find_package_dirs(wheel_dir) for directory in package_dirs: - if directory.endswith(package_name): + if Path(directory).name == package_name: # Prefer using the directory with the same name as the package. return pjoin(directory, lib_sdir) if package_dirs: diff --git a/src/repairwheel/_vendor/delocate/fuse.py b/src/repairwheel/_vendor/delocate/fuse.py index 10468e8..63e7c50 100644 --- a/src/repairwheel/_vendor/delocate/fuse.py +++ b/src/repairwheel/_vendor/delocate/fuse.py @@ -15,9 +15,8 @@ import os import shutil -from os.path import abspath, exists +from os.path import abspath, exists, relpath, splitext from os.path import join as pjoin -from os.path import relpath, splitext from .tmpdirs import InTemporaryDirectory from .tools import ( diff --git a/src/repairwheel/_vendor/delocate/libsana.py b/src/repairwheel/_vendor/delocate/libsana.py index 78c4747..6e1e15b 100644 --- a/src/repairwheel/_vendor/delocate/libsana.py +++ b/src/repairwheel/_vendor/delocate/libsana.py @@ -7,9 +7,8 @@ import os import sys import warnings -from os.path import basename, dirname +from os.path import basename, dirname, realpath from os.path import join as pjoin -from os.path import realpath from pathlib import Path from typing import ( Callable, @@ -430,7 +429,7 @@ def tree_libs( See: - * https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html # noqa: E501 + * https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html * http://matthew-brett.github.io/pydagogue/mac_runtime_link.html .. deprecated:: 0.9 diff --git a/src/repairwheel/_vendor/delocate/wheeltools.py b/src/repairwheel/_vendor/delocate/wheeltools.py index 14e9ff3..41c2280 100644 --- a/src/repairwheel/_vendor/delocate/wheeltools.py +++ b/src/repairwheel/_vendor/delocate/wheeltools.py @@ -10,11 +10,9 @@ import os import sys from itertools import product -from os.path import abspath, basename, dirname, exists +from os.path import abspath, basename, dirname, exists, relpath, splitext from os.path import join as pjoin -from os.path import relpath from os.path import sep as psep -from os.path import splitext from typing import Iterable, Optional, Union, overload from packaging.utils import parse_wheel_filename diff --git a/src/repairwheel/_vendor/vendor.txt b/src/repairwheel/_vendor/vendor.txt index 5d13b5f..6e0d6e8 100644 --- a/src/repairwheel/_vendor/vendor.txt +++ b/src/repairwheel/_vendor/vendor.txt @@ -1,2 +1,2 @@ git+https://github.com/pypa/auditwheel.git@1def5d7d3a777946ba1fb6361aec790c67ed710f -delocate==0.10.6 +delocate==0.10.7 diff --git a/tools/vendoring/patches/delocate.chmod.patch b/tools/vendoring/patches/delocate.chmod.patch deleted file mode 100644 index 4a1fce7..0000000 --- a/tools/vendoring/patches/delocate.chmod.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vendor/delocate/delocating.py -index dbdcd80..a8ca72d 100644 ---- a/src/repairwheel/_vendor/delocate/delocating.py -+++ b/src/repairwheel/_vendor/delocate/delocating.py -@@ -7,6 +7,7 @@ import functools - import logging - import os - import shutil -+import stat - import warnings - from os.path import abspath, basename, dirname, exists - from os.path import join as pjoin -@@ -188,6 +189,9 @@ def _copy_required_libs( - "Copying library %s to %s", old_path, relpath(new_path, root_path) - ) - shutil.copy(old_path, new_path) -+ statinfo = os.stat(new_path) -+ if not statinfo.st_mode & stat.S_IWRITE: -+ os.chmod(new_path, statinfo.st_mode | stat.S_IWRITE) - # Delocate this file now that it is stored locally. - needs_delocating.add(new_path) - # Update out_lib_dict with the new file paths. diff --git a/tools/vendoring/patches/delocate.patch b/tools/vendoring/patches/delocate.patch index c425f6b..3f04379 100644 --- a/tools/vendoring/patches/delocate.patch +++ b/tools/vendoring/patches/delocate.patch @@ -1,130 +1,128 @@ diff --git a/src/repairwheel/_vendor/delocate/cmd/common.py b/src/repairwheel/_vendor/delocate/cmd/common.py -index d6878e5..24959f6 100644 +index d4457e4..f0c26a9 100644 --- a/src/repairwheel/_vendor/delocate/cmd/common.py +++ b/src/repairwheel/_vendor/delocate/cmd/common.py -@@ -10,7 +10,7 @@ import sys - from optparse import Option, OptionParser, Values - from typing import Callable, List +@@ -14,8 +14,8 @@ from typing import Callable, Iterable, Iterator, List + from typing_extensions import Literal, TypedDict + +-from delocate import __version__ -from delocate.delocating import filter_system_libs ++from .. import __version__ +from ..delocating import filter_system_libs - from typing_extensions import Literal, TypedDict logger = logging.getLogger(__name__) - + diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py b/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py -index cfbe57b..cc8f4c5 100644 +index f858fe3..df0fef0 100755 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_addplat.py -@@ -23,9 +23,9 @@ from os.path import expanduser +@@ -21,8 +21,8 @@ from argparse import ArgumentParser + from os.path import expanduser, realpath from os.path import join as exists - from os.path import realpath --from delocate import __version__ --from delocate.cmd.common import verbosity_args, verbosity_config +-from delocate.cmd.common import common_parser, glob_paths, verbosity_config -from delocate.wheeltools import WheelToolsError, add_platforms -+from .. import __version__ -+from ..cmd.common import verbosity_args, verbosity_config ++from ..cmd.common import common_parser, glob_paths, verbosity_config +from ..wheeltools import WheelToolsError, add_platforms - - def main() -> None: + parser = ArgumentParser(description=__doc__, parents=[common_parser]) + parser.add_argument( diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py b/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py -index 9fe6e31..3ab2ec5 100644 +index 80d46a1..e6025cc 100755 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_fuse.py -@@ -11,9 +11,9 @@ from optparse import Option, OptionParser +@@ -10,8 +10,8 @@ from argparse import ArgumentParser from os.path import abspath, basename, expanduser from os.path import join as pjoin --from delocate import __version__ --from delocate.cmd.common import verbosity_args, verbosity_config +-from delocate.cmd.common import common_parser, verbosity_config -from delocate.fuse import fuse_wheels -+from .. import __version__ -+from ..cmd.common import verbosity_args, verbosity_config ++from ..cmd.common import common_parser, verbosity_config +from ..fuse import fuse_wheels - - def main() -> None: + parser = ArgumentParser(description=__doc__, parents=[common_parser]) + parser.add_argument( diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py b/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py -index 35ba44a..abde4e6 100644 +index e9bc691..558adc4 100755 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_listdeps.py -@@ -10,10 +10,10 @@ from os import getcwd +@@ -9,10 +9,10 @@ from os import getcwd from os.path import isdir, realpath from os.path import sep as psep --from delocate import __version__, wheel_libs --from delocate.cmd.common import verbosity_args, verbosity_config +-from delocate import wheel_libs +-from delocate.cmd.common import common_parser, glob_paths, verbosity_config -from delocate.delocating import filter_system_libs -from delocate.libsana import stripped_lib_dict, tree_libs_from_directory -+from .. import __version__, wheel_libs -+from ..cmd.common import verbosity_args, verbosity_config ++from .. import wheel_libs ++from ..cmd.common import common_parser, glob_paths, verbosity_config +from ..delocating import filter_system_libs +from ..libsana import stripped_lib_dict, tree_libs_from_directory - - def main() -> None: + parser = ArgumentParser(description=__doc__, parents=[common_parser]) + parser.add_argument( diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py b/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py -index 9dfa305..39f0d70 100644 +index 07c2f7d..3ea52e0 100755 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_patch.py -@@ -12,8 +12,8 @@ from optparse import Option, OptionParser +@@ -11,8 +11,8 @@ from argparse import ArgumentParser from os.path import basename, exists, expanduser from os.path import join as pjoin --from delocate import __version__, patch_wheel --from delocate.cmd.common import verbosity_args, verbosity_config -+from .. import __version__, patch_wheel -+from ..cmd.common import verbosity_args, verbosity_config - +-from delocate import patch_wheel +-from delocate.cmd.common import common_parser, verbosity_config ++from .. import patch_wheel ++from ..cmd.common import common_parser, verbosity_config - def main() -> None: + parser = ArgumentParser(description=__doc__, parents=[common_parser]) + parser.add_argument( diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_path.py b/src/repairwheel/_vendor/delocate/cmd/delocate_path.py -index 78f4b9c..b2109c5 100644 +index a2dd101..8e303ea 100755 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_path.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_path.py -@@ -8,8 +8,8 @@ import os - import sys - from optparse import Option, OptionParser +@@ -7,8 +7,8 @@ from __future__ import absolute_import, division, print_function + import os + from argparse import ArgumentParser --from delocate import __version__, delocate_path +-from delocate import delocate_path -from delocate.cmd.common import ( -+from .. import __version__, delocate_path ++from .. import delocate_path +from ..cmd.common import ( - delocate_args, + common_parser, + delocate_parser, delocate_values, - verbosity_args, diff --git a/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py b/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py -index 9e6f45d..9d727ce 100644 +index ebf2918..e28aac3 100755 --- a/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py +++ b/src/repairwheel/_vendor/delocate/cmd/delocate_wheel.py -@@ -13,8 +13,8 @@ from os.path import basename, exists, expanduser +@@ -12,8 +12,8 @@ from os.path import basename, exists, expanduser from os.path import join as pjoin from typing import List, Optional, Text --from delocate import __version__, delocate_wheel +-from delocate import delocate_wheel -from delocate.cmd.common import ( -+from .. import __version__, delocate_wheel ++from .. import delocate_wheel +from ..cmd.common import ( - delocate_args, + common_parser, + delocate_parser, delocate_values, - verbosity_args, -diff -u b/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vendor/delocate/delocating.py ---- b/src/repairwheel/_vendor/delocate/delocating.py +diff --git a/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vendor/delocate/delocating.py +index 38c2fde..d873622 100644 +--- a/src/repairwheel/_vendor/delocate/delocating.py +++ b/src/repairwheel/_vendor/delocate/delocating.py -@@ -11,6 +11,7 @@ - from os.path import abspath, basename, dirname, exists +@@ -7,6 +7,7 @@ import functools + import logging + import os + import shutil ++import stat + import warnings + from os.path import abspath, basename, dirname, exists, realpath, relpath from os.path import join as pjoin - from os.path import realpath, relpath -+from pathlib import Path - from subprocess import PIPE, Popen - from typing import ( - Callable, -@@ -55,6 +56,11 @@ +@@ -56,6 +57,11 @@ class DelocationError(Exception): pass - - + + +def posix_relpath(path: str, start: str = None) -> str: + rel = relpath(path, start) + return Path(rel).as_posix() @@ -133,7 +131,7 @@ diff -u b/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vend def delocate_tree_libs( lib_dict: Mapping[Text, Mapping[Text, Text]], lib_path: Text, -@@ -137,7 +143,7 @@ +@@ -157,7 +163,7 @@ def _analyze_tree_libs( # @rpath, etc, at this point should never happen. raise DelocationError("%s was expected to be resolved." % required) r_ed_base = basename(required) @@ -142,7 +140,17 @@ diff -u b/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vend # Not local, plan to copy if r_ed_base in copied_basenames: raise DelocationError( -@@ -204,7 +210,7 @@ +@@ -202,6 +208,9 @@ def _copy_required_libs( + "Copying library %s to %s", old_path, relpath(new_path, root_path) + ) + shutil.copy(old_path, new_path) ++ statinfo = os.stat(new_path) ++ if not statinfo.st_mode & stat.S_IWRITE: ++ os.chmod(new_path, statinfo.st_mode | stat.S_IWRITE) + # Delocate this file now that it is stored locally. + needs_delocating.add(new_path) + # Update out_lib_dict with the new file paths. +@@ -224,7 +233,7 @@ def _update_install_names( for required in files_to_delocate: # Set relative path for local library for requiring, orig_install_name in lib_dict[required].items(): @@ -151,7 +159,7 @@ diff -u b/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vend new_install_name = "@loader_path/" + req_rel if orig_install_name == new_install_name: logger.info( -@@ -382,6 +388,8 @@ +@@ -402,6 +411,8 @@ def _dylibs_only(filename: str) -> bool: def filter_system_libs(libname: str) -> bool: @@ -160,7 +168,7 @@ diff -u b/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vend return not (libname.startswith("/usr/lib") or libname.startswith("/System")) -@@ -670,7 +678,7 @@ +@@ -701,7 +712,7 @@ def delocate_wheel( ] _make_install_name_ids_unique( libraries=libraries_in_lib_path, @@ -169,18 +177,19 @@ diff -u b/src/repairwheel/_vendor/delocate/delocating.py b/src/repairwheel/_vend ) rewrite_record(wheel_dir) if len(copied_libs) or not in_place: -unchanged: +diff --git a/src/repairwheel/_vendor/delocate/libsana.py b/src/repairwheel/_vendor/delocate/libsana.py +index 3cde5ca..6e1e15b 100644 --- a/src/repairwheel/_vendor/delocate/libsana.py +++ b/src/repairwheel/_vendor/delocate/libsana.py -@@ -10,6 +10,7 @@ import warnings - from os.path import basename, dirname +@@ -9,6 +9,7 @@ import sys + import warnings + from os.path import basename, dirname, realpath from os.path import join as pjoin - from os.path import realpath +from pathlib import Path from typing import ( Callable, Dict, -@@ -22,7 +23,7 @@ from typing import ( +@@ -21,7 +22,7 @@ from typing import ( Tuple, ) @@ -189,7 +198,7 @@ unchanged: from .tmpdirs import TemporaryDirectory from .tools import ( -@@ -42,6 +43,8 @@ class DependencyNotFound(Exception): +@@ -41,6 +42,8 @@ class DependencyNotFound(Exception): def _filter_system_libs(libname: Text) -> bool: @@ -198,7 +207,7 @@ unchanged: return not (libname.startswith("/usr/lib") or libname.startswith("/System")) -@@ -318,7 +321,7 @@ def _tree_libs_from_libraries( +@@ -317,7 +320,7 @@ def _tree_libs_from_libraries( if missing_libs and not ignore_missing: # get_dependencies will already have logged details of missing # libraries. @@ -208,16 +217,15 @@ unchanged: ) diff --git a/src/repairwheel/_vendor/delocate/wheeltools.py b/src/repairwheel/_vendor/delocate/wheeltools.py -index f43546a..14e9ff3 100644 +index 575f032..41c2280 100644 --- a/src/repairwheel/_vendor/delocate/wheeltools.py +++ b/src/repairwheel/_vendor/delocate/wheeltools.py -@@ -17,9 +17,9 @@ from os.path import sep as psep - from os.path import splitext - from typing import Iterable, Optional, Union, overload +@@ -17,8 +17,7 @@ from typing import Iterable, Optional, Union, overload --from delocate.pkginfo import read_pkg_info, write_pkg_info from packaging.utils import parse_wheel_filename +-from delocate.pkginfo import read_pkg_info, write_pkg_info +- +from .pkginfo import read_pkg_info, write_pkg_info from .tmpdirs import InTemporaryDirectory from .tools import dir2zip, open_rw, unique_by_index, zip2dir