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