Debian Codegraph @

skmisc/__config__.py.in

raw ◀ ▶
1 Debian patch touch this file
1 # This file is generated by scikit-miscs's build process
2 # It contains system_info results at the time of building this package.
3 from enum import Enum
•4 import sys
5 import sysconfig
6
7 __all__ = ["show"]
8 _built_with_meson = True
9
10
11 class DisplayModes(Enum):
12 stdout = "stdout"
13 dicts = "dicts"
14
15
16 def _cleanup(d):
17 """
18 Removes empty values in a `dict` recursively
19 This ensures we remove values that Meson could not provide to CONFIG
20 """
21 if isinstance(d, dict):
22 return { k: _cleanup(v) for k, v in d.items() if v != '' and _cleanup(v) != '' }
23 else:
24 return d
25
26
27 CONFIG = _cleanup(
28 {
29 "Compilers": {
30 "c": {
31 "name": "@C_COMP@",
32 "linker": "@C_COMP_LINKER_ID@",
33 "version": "@C_COMP_VERSION@",
34 "commands": "@C_COMP_CMD_ARRAY@",
35 },
36 "cython": {
37 "name": "@CYTHON_COMP@",
38 "linker": "@CYTHON_COMP_LINKER_ID@",
39 "version": "@CYTHON_COMP_VERSION@",
40 "commands": "@CYTHON_COMP_CMD_ARRAY@",
41 },
42 "fortran": {
43 "name": "@FORTRAN_COMP@",
44 "linker": "@FORTRAN_COMP_LINKER_ID@",
45 "version": "@FORTRAN_COMP_VERSION@",
46 "commands": "@FORTRAN_COMP_CMD_ARRAY@",
47 },
48 },
49 "Build Dependencies": {
50 "blas": {
51 "name": "@BLAS_NAME@",
52 "found": bool("@BLAS_FOUND@".lower().replace('false', '')),
53 "version": "@BLAS_VERSION@",
54 "detection method": "@BLAS_TYPE_NAME@",
55 "include directory": r"@BLAS_INCLUDEDIR@",
56 "lib directory": r"@BLAS_LIBDIR@",
57 "openblas configuration": "@BLAS_OPENBLAS_CONFIG@",
58 "pc file directory": r"@BLAS_PCFILEDIR@",
59 },
60 "lapack": {
61 "name": "@LAPACK_NAME@",
62 "found": bool("@LAPACK_FOUND@".lower().replace('false', '')),
63 "version": "@LAPACK_VERSION@",
64 "detection method": "@LAPACK_TYPE_NAME@",
65 "include directory": r"@LAPACK_INCLUDEDIR@",
66 "lib directory": r"@LAPACK_LIBDIR@",
67 "openblas configuration": "@LAPACK_OPENBLAS_CONFIG@",
68 "pc file directory": r"@LAPACK_PCFILEDIR@",
69 },
70 },
71 "Machine Information": {
72 "host": {
73 "cpu": "@HOST_CPU@",
74 "family": "@HOST_CPU_FAMILY@",
75 "endian": "@HOST_CPU_ENDIAN@",
76 "system": "@HOST_CPU_SYSTEM@",
77 },
78 "build": {
79 "cpu": "@BUILD_CPU@",
80 "family": "@BUILD_CPU_FAMILY@",
81 "endian": "@BUILD_CPU_ENDIAN@",
82 "system": "@BUILD_CPU_SYSTEM@",
83 },
84 "cross-compiled": bool("@CROSS_COMPILED@".lower().replace('false', '')),
85 },
86 "Python Information": {
•87 "path": sys.executable,
88 "version": sysconfig.get_config_var("py_version_short"),
89 },
90 }
91 )
92
93
94 def _check_pyyaml():
95 import yaml
96
97 return yaml
98
99
100 def show(mode=DisplayModes.stdout.value):
101 """
102 Show libraries and system information on which scikit-misc was built
103 and is being used
104
105 Parameters
106 ----------
107 mode : {`'stdout'`, `'dicts'`}, optional.
108 Indicates how to display the config information.
109 `'stdout'` prints to console, `'dicts'` returns a dictionary
110 of the configuration.
111
112 Returns
113 -------
114 out : {`dict`, `None`}
115 If mode is `'dicts'`, a dict is returned, else None
116
117 Notes
118 -----
119 1. The `'stdout'` mode will give more readable
120 output if ``pyyaml`` is installed
121
122 """
123 if mode == DisplayModes.stdout.value:
124 try: # Non-standard library, check import
125 yaml = _check_pyyaml()
126
127 print(yaml.dump(CONFIG))
128 except ModuleNotFoundError:
129 import warnings
130 import json
131
132 warnings.warn("Install `pyyaml` for better output", stacklevel=1)
133 print(json.dumps(CONFIG, indent=2))
134 elif mode == DisplayModes.dicts.value:
135 return CONFIG
136 else:
137 raise AttributeError(
138 f"Invalid `mode`, use one of: {', '.join([e.value for e in DisplayModes])}"
139 )