MCPcopy Index your code
hub / github.com/numpy/numpy / install_temp

Function install_temp

numpy/_core/tests/test_limited_api.py:38–82  ·  view source on GitHub ↗
(tmpdir_factory)

Source from the content-addressed store, hash-verified

36
37@pytest.fixture(scope='module')
38def install_temp(tmpdir_factory):
39 # Based in part on test_cython from random.tests.test_extending
40 if IS_WASM:
41 pytest.skip("No subprocess")
42
43 # Build against a copy of the sources placed next to the build dir:
44 # meson refers to sources via paths relative to the build dir, and on
45 # Windows the unnormalized cwd + `..` chain joining the deeply nested
46 # pytest tmp dir and site-packages can exceed MAX_PATH, failing the
47 # compile with "Cannot open source file".
48 tmp_root = tmpdir_factory.mktemp("limited_api")
49 srcdir = str(tmp_root / "src")
50 shutil.copytree(
51 os.path.join(os.path.dirname(__file__), 'examples', 'limited_api'),
52 srcdir)
53 build_dir = tmp_root / "build"
54 os.makedirs(build_dir, exist_ok=True)
55 # Ensure we use the correct Python interpreter even when `meson` is
56 # installed in a different Python environment (see gh-24956)
57 native_file = str(build_dir / 'interpreter-native-file.ini')
58 with open(native_file, 'w') as f:
59 f.write("[binaries]\n")
60 f.write(f"python = '{sys.executable}'\n")
61 f.write(f"python3 = '{sys.executable}'")
62
63 try:
64 subprocess.check_call(["meson", "--version"])
65 except FileNotFoundError:
66 pytest.skip("No usable 'meson' found")
67 if sysconfig.get_platform() == "win-arm64":
68 pytest.skip("Meson unable to find MSVC linker on win-arm64")
69 if sys.platform == "win32":
70 run_subprocess(["meson", "setup",
71 "--werror",
72 "--buildtype=release",
73 "--vsenv", "--native-file", native_file,
74 str(srcdir)],
75 build_dir)
76 else:
77 run_subprocess(["meson", "setup", "--werror",
78 "--native-file", native_file, str(srcdir)],
79 build_dir)
80 run_subprocess(["meson", "compile", "-vv"], build_dir)
81
82 sys.path.append(str(build_dir))
83
84
85@pytest.mark.skipif(IS_WASM, reason="Can't start subprocess")

Callers

nothing calls this directly

Calls 4

run_subprocessFunction · 0.90
openFunction · 0.85
joinMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…