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(
"std", [11, 0])
15 monkeypatch.chdir(tmpdir)
16 monkeypatch.syspath_prepend(MAIN_DIR)
18 (tmpdir /
"setup.py").write_text(
22 sys.path.append({MAIN_DIR!r}) 24 from setuptools import setup, Extension 25 from pybind11.setup_helpers import build_ext, Pybind11Extension 39 cmdclass["build_ext"] = build_ext 43 name="simple_setup_package", 45 ext_modules=ext_modules, 48 ).format(MAIN_DIR=MAIN_DIR, std=std),
52 (tmpdir /
"main.cpp").write_text(
55 #include <pybind11/pybind11.h> 60 PYBIND11_MODULE(simple_setup, m) { 68 subprocess.check_call(
69 [sys.executable,
"setup.py",
"build_ext",
"--inplace"],
75 for item
in tmpdir.listdir():
79 len([f
for f
in tmpdir.listdir()
if f.basename.startswith(
"simple_setup")]) == 1
81 assert len(
list(tmpdir.listdir())) == 4
83 (tmpdir /
"test.py").write_text(
87 assert simple_setup.f(3) == 9 93 subprocess.check_call(
94 [sys.executable,
"test.py"], stdout=sys.stdout, stderr=sys.stderr
void print(const Matrix &A, const string &s, ostream &stream)
def test_simple_setup_py(monkeypatch, tmpdir, std)