|
8 | 8 | from collections import OrderedDict
|
9 | 9 | from os.path import exists, basename, abspath, isabs, dirname
|
10 | 10 | from os.path import join as pjoin
|
| 11 | +from subprocess import check_call |
11 | 12 | from typing import Dict, Optional, Tuple
|
12 | 13 |
|
13 | 14 | from auditwheel.patcher import ElfPatcher
|
|
28 | 29 |
|
29 | 30 |
|
30 | 31 | def repair_wheel(wheel_path: str, abi: str, lib_sdir: str, out_dir: str,
|
31 |
| - update_tags: bool, patcher: ElfPatcher) -> Optional[str]: |
| 32 | + update_tags: bool, patcher: ElfPatcher, |
| 33 | + strip: bool = False) -> Optional[str]: |
32 | 34 |
|
33 | 35 | external_refs_by_fn = get_wheel_elfdata(wheel_path)[1]
|
34 | 36 |
|
@@ -88,9 +90,21 @@ def repair_wheel(wheel_path: str, abi: str, lib_sdir: str, out_dir: str,
|
88 | 90 | if update_tags:
|
89 | 91 | ctx.out_wheel = add_platforms(ctx, [abi],
|
90 | 92 | get_replace_platforms(abi))
|
| 93 | + |
| 94 | + if strip: |
| 95 | + libs_to_strip = [path for (_, path) in soname_map.values()] |
| 96 | + extensions = external_refs_by_fn.keys() |
| 97 | + strip_symbols(itertools.chain(libs_to_strip, extensions)) |
| 98 | + |
91 | 99 | return ctx.out_wheel
|
92 | 100 |
|
93 | 101 |
|
| 102 | +def strip_symbols(libraries): |
| 103 | + for lib in libraries: |
| 104 | + logger.info('Stripping symbols from %s', lib) |
| 105 | + check_call(['strip', '-s', lib]) |
| 106 | + |
| 107 | + |
94 | 108 | def copylib(src_path, dest_dir, patcher):
|
95 | 109 | """Graft a shared library from the system into the wheel and update the
|
96 | 110 | relevant links.
|
|
0 commit comments