5 from textwrap
import dedent
9 DIR = os.path.abspath(os.path.dirname(__file__))
10 MAIN_DIR = os.path.dirname(os.path.dirname(DIR))
13 @pytest.mark.parametrize(
"parallel", [
False,
True])
14 @pytest.mark.parametrize(
"std", [11, 0])
16 monkeypatch.chdir(tmpdir)
17 monkeypatch.syspath_prepend(MAIN_DIR)
19 (tmpdir /
"setup.py").write_text(
23 sys.path.append({MAIN_DIR!r})
25 from setuptools import setup, Extension
26 from pybind11.setup_helpers import build_ext, Pybind11Extension
40 cmdclass["build_ext"] = build_ext
45 from pybind11.setup_helpers import ParallelCompile
46 ParallelCompile().install()
49 name="simple_setup_package",
51 ext_modules=ext_modules,
54 ).format(MAIN_DIR=MAIN_DIR, std=std, parallel=parallel),
58 (tmpdir /
"main.cpp").write_text(
61 #include <pybind11/pybind11.h>
66 PYBIND11_MODULE(simple_setup, m) {
74 subprocess.check_call(
75 [sys.executable,
"setup.py",
"build_ext",
"--inplace"],
81 for item
in tmpdir.listdir():
85 len([f
for f
in tmpdir.listdir()
if f.basename.startswith(
"simple_setup")]) == 1
87 assert len(
list(tmpdir.listdir())) == 4
89 (tmpdir /
"test.py").write_text(
93 assert simple_setup.f(3) == 9
99 subprocess.check_call(
100 [sys.executable,
"test.py"], stdout=sys.stdout, stderr=sys.stderr