|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import importlib
|
4 |
| -import os |
5 | 4 | import platform
|
6 | 5 | import sys
|
7 | 6 | import zipfile
|
8 | 7 | from argparse import Namespace
|
9 | 8 | from datetime import datetime, timezone
|
10 |
| -from os.path import isabs |
11 | 9 | from pathlib import Path
|
12 | 10 | from unittest.mock import Mock
|
13 | 11 |
|
|
23 | 21 |
|
24 | 22 |
|
25 | 23 | @pytest.mark.parametrize(
|
26 |
| - ("file", "external_libs", "exclude"), |
| 24 | + ("file", "external_libs", "exclude", "env"), |
27 | 25 | [
|
28 | 26 | (
|
29 | 27 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
30 | 28 | {"libffi.so.5", "libpython2.7.so.1.0"},
|
31 | 29 | frozenset(),
|
| 30 | + None, |
32 | 31 | ),
|
33 | 32 | (
|
34 | 33 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
35 | 34 | set(),
|
36 | 35 | frozenset(["libffi.so.5", "libpython2.7.so.1.0"]),
|
| 36 | + None, |
37 | 37 | ),
|
38 | 38 | (
|
39 | 39 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
40 | 40 | {"libffi.so.5", "libpython2.7.so.1.0"},
|
41 | 41 | frozenset(["libffi.so.noexist", "libnoexist.so.*"]),
|
| 42 | + None, |
42 | 43 | ),
|
43 | 44 | (
|
44 | 45 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
45 | 46 | {"libpython2.7.so.1.0"},
|
46 | 47 | frozenset(["libffi.so.[4,5]"]),
|
| 48 | + None, |
47 | 49 | ),
|
48 | 50 | (
|
49 | 51 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
50 | 52 | {"libffi.so.5", "libpython2.7.so.1.0"},
|
51 | 53 | frozenset(["libffi.so.[6,7]"]),
|
| 54 | + None, |
52 | 55 | ),
|
53 | 56 | (
|
54 | 57 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
55 | 58 | {"libpython2.7.so.1.0"},
|
56 | 59 | frozenset([f"{HERE}/*"]),
|
| 60 | + "LD_LIBRARY_PATH", |
57 | 61 | ),
|
58 | 62 | (
|
59 | 63 | "cffi-1.5.0-cp27-none-linux_x86_64.whl",
|
60 | 64 | {"libpython2.7.so.1.0"},
|
61 | 65 | frozenset(["libffi.so.*"]),
|
| 66 | + None, |
62 | 67 | ),
|
63 |
| - ("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"])), |
| 68 | + ("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"]), None), |
64 | 69 | (
|
65 | 70 | "python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl",
|
66 | 71 | {"libsnappy.so.1"},
|
67 | 72 | frozenset(),
|
| 73 | + None, |
68 | 74 | ),
|
69 | 75 | ],
|
70 | 76 | )
|
71 |
| -def test_analyze_wheel_abi(file, external_libs, exclude): |
| 77 | +def test_analyze_wheel_abi(file, external_libs, exclude, env): |
72 | 78 | # If exclude libs contain path, LD_LIBRARY_PATH need to be modified to find the libs
|
73 | 79 | # `lddtree.load_ld_paths` needs to be reloaded for it's `lru_cache`-ed.
|
74 |
| - modify_ld_library_path = any(isabs(e) for e in exclude) |
75 | 80 |
|
76 | 81 | with pytest.MonkeyPatch.context() as cp:
|
77 |
| - if modify_ld_library_path: |
78 |
| - cp.setenv("LD_LIBRARY_PATH", f"{HERE}") |
| 82 | + if env: |
| 83 | + cp.setenv(env, f"{HERE}") |
79 | 84 | importlib.reload(lddtree)
|
80 | 85 |
|
81 | 86 | winfo = analyze_wheel_abi(
|
82 | 87 | Libc.GLIBC, Architecture.x86_64, HERE / file, exclude, False, True
|
83 | 88 | )
|
84 | 89 | assert set(winfo.external_refs["manylinux_2_5_x86_64"].libs) == external_libs, (
|
85 |
| - f"{HERE}, {exclude}, {os.environ}" |
| 90 | + f"{HERE}, {exclude}, {env}" |
86 | 91 | )
|
87 | 92 |
|
88 |
| - if modify_ld_library_path: |
| 93 | + if env: |
89 | 94 | importlib.reload(lddtree)
|
90 | 95 |
|
91 | 96 |
|
|
0 commit comments