|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
| 3 | +import importlib |
| 4 | +import os |
3 | 5 | import platform
|
4 | 6 | import subprocess
|
5 | 7 | import sys
|
6 | 8 | import zipfile
|
7 | 9 | from argparse import Namespace
|
8 | 10 | from datetime import datetime, timezone
|
| 11 | +from os.path import isabs |
9 | 12 | from pathlib import Path
|
10 | 13 | from unittest import mock
|
11 | 14 | from unittest.mock import Mock
|
12 | 15 |
|
13 | 16 | import pytest
|
14 | 17 |
|
15 |
| -from auditwheel import main_repair |
| 18 | +from auditwheel import lddtree, main_repair |
16 | 19 | from auditwheel.libc import Libc
|
17 | 20 | from auditwheel.policy import WheelPolicies
|
18 | 21 | from auditwheel.wheel_abi import analyze_wheel_abi
|
|
40 | 43 | {"libffi.so.5"},
|
41 | 44 | frozenset(["libffi.so.[6,7]"]),
|
42 | 45 | ),
|
| 46 | + ( |
| 47 | + "cffi-1.5.0-cp27-none-linux_x86_64.whl", |
| 48 | + set(), |
| 49 | + frozenset([f"{HERE}/*"]), |
| 50 | + ), |
43 | 51 | ("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.*"])),
|
44 | 52 | ("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"])),
|
45 | 53 | (
|
|
50 | 58 | ],
|
51 | 59 | )
|
52 | 60 | def test_analyze_wheel_abi(file, external_libs, exclude):
|
53 |
| - wheel_policies = WheelPolicies(libc=Libc.GLIBC, arch="x86_64") |
54 |
| - winfo = analyze_wheel_abi(wheel_policies, str(HERE / file), exclude) |
55 |
| - assert set(winfo.external_refs["manylinux_2_5_x86_64"]["libs"]) == external_libs |
| 61 | + # If exclude libs contain path, LD_LIBRARY_PATH need to be modified to find the libs |
| 62 | + # `lddtree.load_ld_paths` needs to be reloaded for it's `lru_cache`-ed. |
| 63 | + modify_ld_library_path = any(isabs(e) for e in exclude) |
| 64 | + |
| 65 | + with pytest.MonkeyPatch.context() as cp: |
| 66 | + if modify_ld_library_path: |
| 67 | + cp.setenv("LD_LIBRARY_PATH", f"{HERE}") |
| 68 | + importlib.reload(lddtree) |
| 69 | + |
| 70 | + wheel_policies = WheelPolicies(libc=Libc.GLIBC, arch="x86_64") |
| 71 | + winfo = analyze_wheel_abi(wheel_policies, str(HERE / file), exclude) |
| 72 | + assert ( |
| 73 | + set(winfo.external_refs["manylinux_2_5_x86_64"]["libs"]) == external_libs |
| 74 | + ), f"{HERE}, {exclude}, {os.environ}" |
| 75 | + |
| 76 | + if modify_ld_library_path: |
| 77 | + importlib.reload(lddtree) |
56 | 78 |
|
57 | 79 |
|
58 | 80 | def test_analyze_wheel_abi_pyfpe():
|
|
0 commit comments