|
| 1 | +from enum import Enum |
| 2 | +from types import ModuleType |
| 3 | +from typing import Final, Literal as L, TypedDict, overload, type_check_only |
| 4 | +from typing_extensions import NotRequired |
| 5 | + |
| 6 | +_CompilerConfigDictValue = TypedDict( |
| 7 | + "_CompilerConfigDictValue", |
| 8 | + { |
| 9 | + "name": str, |
| 10 | + "linker": str, |
| 11 | + "version": str, |
| 12 | + "commands": str, |
| 13 | + "args": str, |
| 14 | + "linker args": str, |
| 15 | + }, |
| 16 | +) |
| 17 | +_CompilerConfigDict = TypedDict( |
| 18 | + "_CompilerConfigDict", |
| 19 | + { |
| 20 | + "c": _CompilerConfigDictValue, |
| 21 | + "cython": _CompilerConfigDictValue, |
| 22 | + "c++": _CompilerConfigDictValue, |
| 23 | + }, |
| 24 | +) |
| 25 | +_MachineInformationDict = TypedDict( |
| 26 | + "_MachineInformationDict", |
| 27 | + { |
| 28 | + "host": _MachineInformationDictValue, |
| 29 | + "build": _MachineInformationDictValue, |
| 30 | + "cross-compiled": NotRequired[L[True]], |
| 31 | + }, |
| 32 | +) |
| 33 | + |
| 34 | +@type_check_only |
| 35 | +class _MachineInformationDictValue(TypedDict): |
| 36 | + cpu: str |
| 37 | + family: str |
| 38 | + endian: L["little", "big"] |
| 39 | + system: str |
| 40 | + |
| 41 | +_BuildDependenciesDictValue = TypedDict( |
| 42 | + "_BuildDependenciesDictValue", |
| 43 | + { |
| 44 | + "name": str, |
| 45 | + "found": NotRequired[L[True]], |
| 46 | + "version": str, |
| 47 | + "include directory": str, |
| 48 | + "lib directory": str, |
| 49 | + "openblas configuration": str, |
| 50 | + "pc file directory": str, |
| 51 | + }, |
| 52 | +) |
| 53 | + |
| 54 | +class _BuildDependenciesDict(TypedDict): |
| 55 | + blas: _BuildDependenciesDictValue |
| 56 | + lapack: _BuildDependenciesDictValue |
| 57 | + |
| 58 | +class _PythonInformationDict(TypedDict): |
| 59 | + path: str |
| 60 | + version: str |
| 61 | + |
| 62 | +_SIMDExtensionsDict = TypedDict( |
| 63 | + "_SIMDExtensionsDict", |
| 64 | + { |
| 65 | + "baseline": list[str], |
| 66 | + "found": list[str], |
| 67 | + "not found": list[str], |
| 68 | + }, |
| 69 | +) |
| 70 | + |
| 71 | +_ConfigDict = TypedDict( |
| 72 | + "_ConfigDict", |
| 73 | + { |
| 74 | + "Compilers": _CompilerConfigDict, |
| 75 | + "Machine Information": _MachineInformationDict, |
| 76 | + "Build Dependencies": _BuildDependenciesDict, |
| 77 | + "Python Information": _PythonInformationDict, |
| 78 | + "SIMD Extensions": _SIMDExtensionsDict, |
| 79 | + }, |
| 80 | +) |
| 81 | + |
| 82 | +### |
| 83 | + |
| 84 | +__all__ = ["show_config"] |
| 85 | + |
| 86 | +CONFIG: Final[_ConfigDict] = ... |
| 87 | + |
| 88 | +class DisplayModes(Enum): |
| 89 | + stdout = "stdout" |
| 90 | + dicts = "dicts" |
| 91 | + |
| 92 | +def _check_pyyaml() -> ModuleType: ... |
| 93 | + |
| 94 | +@overload |
| 95 | +def show(mode: L["stdout"] = "stdout") -> None: ... |
| 96 | +@overload |
| 97 | +def show(mode: L["dicts"]) -> _ConfigDict: ... |
| 98 | + |
| 99 | +@overload |
| 100 | +def show_config(mode: L["stdout"] = "stdout") -> None: ... |
| 101 | +@overload |
| 102 | +def show_config(mode: L["dicts"]) -> _ConfigDict: ... |
0 commit comments