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