File: test_bundled_wheels.py

package info (click to toggle)
python-auditwheel 5.3.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: python: 4,270; ansic: 205; cpp: 58; makefile: 20; f90: 12
file content (87 lines) | stat: -rw-r--r-- 2,788 bytes parent folder | download
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
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.wheel_abi import analyze_wheel_abi

HERE = Path(__file__).parent.resolve()


@pytest.mark.skipif(platform.machine() != "x86_64", reason="only supported on x86_64")
@pytest.mark.parametrize(
    "file, external_libs",
    [
        ("cffi-1.5.0-cp27-none-linux_x86_64.whl", {"libffi.so.5"}),
        ("python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl", {"libsnappy.so.1"}),
    ],
)
def test_analyze_wheel_abi(file, external_libs):
    winfo = analyze_wheel_abi(str(HERE / file))
    assert set(winfo.external_refs["manylinux_2_5_x86_64"]["libs"]) == external_libs


@pytest.mark.skipif(platform.machine() != "x86_64", reason="only supported on x86_64")
def test_analyze_wheel_abi_pyfpe():
    winfo = analyze_wheel_abi(str(HERE / "fpewheel-0.0.0-cp35-cp35m-linux_x86_64.whl"))
    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
            )