File: test_setuptools_pep518.py

package info (click to toggle)
scikit-build-core 0.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,408 kB
  • sloc: python: 13,380; ansic: 140; cpp: 134; sh: 27; fortran: 18; makefile: 7
file content (70 lines) | stat: -rw-r--r-- 1,930 bytes parent folder | download | duplicates (2)
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
import sys
import zipfile
from pathlib import Path

import pytest

pytestmark = pytest.mark.setuptools


# TODO: work out why this fails on Cygwin
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.integration
@pytest.mark.broken_on_urct
@pytest.mark.xfail(
    sys.platform.startswith("cygwin"),
    reason="Cygwin fails here with ld errors",
    strict=False,
)
@pytest.mark.usefixtures("package_simple_setuptools_ext")
def test_pep518_wheel(isolated, tmp_path: Path):
    dist = tmp_path / "dist"
    isolated.install("build[virtualenv]")
    isolated.module("build", "--wheel", f"--outdir={dist}")
    (wheel,) = dist.iterdir()
    assert "cmake_example-0.0.1" in wheel.name
    assert wheel.suffix == ".whl"

    with zipfile.ZipFile(wheel) as zf:
        file_names = {Path(n).parts[0] for n in zf.namelist()}

    assert len(file_names) == 2
    assert "cmake_example-0.0.1.dist-info" in file_names
    file_names.remove("cmake_example-0.0.1.dist-info")
    (so_file,) = file_names

    assert so_file.startswith("cmake_example")
    print("SOFILE:", so_file)

    isolated.install(wheel)

    version = isolated.execute("import cmake_example; print(cmake_example.__version__)")
    assert version == "0.0.1"

    add = isolated.execute("import cmake_example; print(cmake_example.add(1, 2))")
    assert add == "3"


@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.integration
@pytest.mark.broken_on_urct
@pytest.mark.xfail(
    sys.platform.startswith("cygwin"),
    reason="Cygwin fails here with ld errors",
    strict=False,
)
@pytest.mark.usefixtures("package_simple_setuptools_ext")
def test_pep518_pip(isolated):
    isolated.install("-v", ".")

    version = isolated.execute(
        "import cmake_example; print(cmake_example.__version__)",
    )
    assert version == "0.0.1"

    add = isolated.execute(
        "import cmake_example; print(cmake_example.add(1, 2))",
    )
    assert add == "3"