-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathtest_bundled_wheels.py
100 lines (88 loc) · 3.05 KB
/
test_bundled_wheels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from __future__ import annotations
import platform
import subprocess
import sys
import zipfile
from argparse import Namespace
from datetime import datetime, timezone
from pathlib import Path
from unittest import mock
from unittest.mock import Mock
import pytest
from auditwheel import main_repair
from auditwheel.libc import Libc
from auditwheel.policy import WheelPolicies
from auditwheel.wheel_abi import analyze_wheel_abi
HERE = Path(__file__).parent.resolve()
@pytest.mark.parametrize(
"file, external_libs, exclude",
[
("cffi-1.5.0-cp27-none-linux_x86_64.whl", {"libffi.so.5"}, frozenset()),
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.5"])),
(
"python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl",
{"libsnappy.so.1"},
frozenset(),
),
],
)
def test_analyze_wheel_abi(file, external_libs, exclude):
wheel_policies = WheelPolicies(libc=Libc.GLIBC, arch="x86_64")
winfo = analyze_wheel_abi(wheel_policies, str(HERE / file), exclude)
assert set(winfo.external_refs["manylinux_2_5_x86_64"]["libs"]) == external_libs
def test_analyze_wheel_abi_pyfpe():
wheel_policies = WheelPolicies(libc=Libc.GLIBC, arch="x86_64")
winfo = analyze_wheel_abi(
wheel_policies,
str(HERE / "fpewheel-0.0.0-cp35-cp35m-linux_x86_64.whl"),
frozenset(),
)
assert (
winfo.sym_tag == "manylinux_2_5_x86_64"
) # for external symbols, it could get manylinux1
assert (
winfo.pyfpe_tag == "linux_x86_64"
) # but for having the pyfpe reference, it gets just linux
@pytest.mark.skipif(platform.machine() != "x86_64", reason="only checked on x86_64")
def test_wheel_source_date_epoch(tmp_path, monkeypatch):
wheel_build_path = tmp_path / "wheel"
subprocess.run(
[
sys.executable,
"-m",
"pip",
"wheel",
"--no-deps",
"-w",
wheel_build_path,
HERE / "sample_extension",
],
check=True,
)
wheel_path, *_ = list(wheel_build_path.glob("*.whl"))
wheel_output_path = tmp_path / "out"
args = Namespace(
LIB_SDIR=".libs",
ONLY_PLAT=False,
PLAT="manylinux_2_5_x86_64",
STRIP=False,
UPDATE_TAGS=True,
WHEEL_DIR=str(wheel_output_path),
WHEEL_FILE=[str(wheel_path)],
EXCLUDE=[],
cmd="repair",
func=Mock(),
prog="auditwheel",
verbose=1,
)
monkeypatch.setenv("SOURCE_DATE_EPOCH", "650203200")
# patchelf might not be available as we aren't running in a manylinux container
# here. We don't need need it in this test, so just patch it.
with mock.patch("auditwheel.patcher._verify_patchelf"):
main_repair.execute(args, Mock())
output_wheel, *_ = list(wheel_output_path.glob("*.whl"))
with zipfile.ZipFile(output_wheel) as wheel_file:
for file in wheel_file.infolist():
assert (
datetime(*file.date_time, tzinfo=timezone.utc).timestamp() == 650203200
)