MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_simple_setup_py

Function test_simple_setup_py

tests/extra_setuptools/test_setuphelper.py:17–110  ·  view source on GitHub ↗
(monkeypatch, tmpdir, parallel, std)

Source from the content-addressed store, hash-verified

15@pytest.mark.parametrize("parallel", [False, True])
16@pytest.mark.parametrize("std", [11, 0])
17def test_simple_setup_py(monkeypatch, tmpdir, parallel, std):
18 monkeypatch.chdir(tmpdir)
19 monkeypatch.syspath_prepend(MAIN_DIR)
20
21 (tmpdir / "setup.py").write_text(
22 dedent(
23 f"""\
24 import sys
25 sys.path.append({MAIN_DIR!r})
26
27 from setuptools import setup, Extension
28 from pybind11.setup_helpers import build_ext, Pybind11Extension
29
30 std = {std}
31
32 ext_modules = [
33 Pybind11Extension(
34 "simple_setup",
35 sorted(["main.cpp"]),
36 cxx_std=std,
37 ),
38 ]
39
40 cmdclass = dict()
41 if std == 0:
42 cmdclass["build_ext"] = build_ext
43
44
45 parallel = {parallel}
46 if parallel:
47 from pybind11.setup_helpers import ParallelCompile
48 ParallelCompile().install()
49
50 setup(
51 name="simple_setup_package",
52 cmdclass=cmdclass,
53 ext_modules=ext_modules,
54 )
55 """
56 ),
57 encoding="ascii",
58 )
59
60 (tmpdir / "main.cpp").write_text(
61 dedent(
62 """\
63 #include <pybind11/pybind11.h>
64
65 int f(int x) {
66 return x * 3;
67 }
68 PYBIND11_MODULE(simple_setup, m) {
69 m.def("f", &f);
70 }
71 """
72 ),
73 encoding="ascii",
74 )

Callers

nothing calls this directly

Calls 4

dictClass · 0.85
printFunction · 0.85
lenFunction · 0.85
listClass · 0.85

Tested by

no test coverage detected