CIRCT 23.0.0git
Loading...
Searching...
No Matches
conftest.py
Go to the documentation of this file.
1# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2# See https://llvm.org/LICENSE.txt for license information.
3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5from pathlib import Path
6
7collect_ignore_glob = [
8 "integration/hw/*.py",
9]
10
11
12def _looks_like_runtime_root(root: Path) -> bool:
13 markers = [
14 root / "cmake" / "esiaccelConfig.cmake",
15 root / "cpp" / "cmake" / "esiaccelConfig.cmake",
16 root / "cpp" / "include" / "esi" / "Accelerator.h",
17 root / "lib" / "libESICppRuntime.so",
18 root / "lib" / "libESICppRuntime.dylib",
19 root / "tests" / "cpp",
20 root / "bin",
21 ]
22 return any(marker.exists() for marker in markers)
23
24
25def get_runtime_root() -> Path:
26 """Determine the root directory of the ESI runtime installation. Since we need
27 to support testing in a bunch of different configurations and environments,
28 just semi-brute-force the search."""
29 import esiaccel
30
31 # Keep the unresolved build-tree path first. The integrated CIRCT build uses
32 # symlinks back into the source tree for Python sources, and resolve() would
33 # otherwise discard the build location where the runtime libraries live.
34 package_file = Path(esiaccel.__file__)
35 candidates = [
36 package_file.parent.parent,
37 package_file.parent.parent.parent,
38 package_file.resolve().parent.parent,
39 package_file.resolve().parent.parent.parent,
40 ]
41
42 seen = set()
43 for candidate in candidates:
44 if candidate in seen:
45 continue
46 seen.add(candidate)
47 if _looks_like_runtime_root(candidate):
48 return candidate
49
50 raise FileNotFoundError("Could not determine ESI runtime root directory")
Path get_runtime_root()
Definition conftest.py:25
bool _looks_like_runtime_root(Path root)
Definition conftest.py:12