pyhw 0.12.3__py3-none-any.whl → 0.12.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyhw/__init__.py +1 -1
- pyhw/backend/gpu/linux.py +38 -2
- pyhw/library/lib/iokitCPULib.dylib +0 -0
- pyhw/library/lib/iokitGPULib.dylib +0 -0
- pyhw/library/lib/iokitHostLib.dylib +0 -0
- pyhw/library/lib/nvmlGPULib_amd64.so +0 -0
- pyhw/library/lib/nvmlGPULib_arm64.so +0 -0
- pyhw/library/test/nvmlGPULibTest.py +25 -0
- pyhw/pyhwUtil/pyhwUtil.py +5 -1
- {pyhw-0.12.3.dist-info → pyhw-0.12.5.dist-info}/METADATA +2 -2
- {pyhw-0.12.3.dist-info → pyhw-0.12.5.dist-info}/RECORD +15 -11
- {pyhw-0.12.3.dist-info → pyhw-0.12.5.dist-info}/WHEEL +1 -1
- {pyhw-0.12.3.dist-info → pyhw-0.12.5.dist-info}/entry_points.txt +0 -0
- {pyhw-0.12.3.dist-info → pyhw-0.12.5.dist-info}/licenses/LICENSE +0 -0
- {pyhw-0.12.3.dist-info → pyhw-0.12.5.dist-info}/top_level.txt +0 -0
pyhw/__init__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = '0.12.
|
1
|
+
__version__ = '0.12.5'
|
2
2
|
__author__ = 'xiaoran007'
|
pyhw/backend/gpu/linux.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
from .gpuInfo import GPUInfo
|
2
2
|
from ..cpu import CPUDetect
|
3
3
|
from ...pyhwUtil import getArch
|
4
|
+
from pathlib import Path
|
4
5
|
import pypci
|
6
|
+
import ctypes
|
5
7
|
|
6
8
|
|
7
9
|
class GPUDetectLinux:
|
8
10
|
def __init__(self):
|
9
11
|
self.__gpuInfo = GPUInfo()
|
12
|
+
self.__arch = self.__setArch()
|
10
13
|
|
11
14
|
def getGPUInfo(self):
|
12
15
|
self.__getGPUInfo()
|
@@ -18,14 +21,39 @@ class GPUDetectLinux:
|
|
18
21
|
if len(gpu_devices) == 0:
|
19
22
|
self.__handleNonePciDevices()
|
20
23
|
else:
|
24
|
+
core_map = dict()
|
21
25
|
for device in gpu_devices:
|
26
|
+
record_cores = core_map.get(device.device_id, 0)
|
27
|
+
if record_cores != 0:
|
28
|
+
pass
|
29
|
+
else:
|
30
|
+
cores = self.__getGPUInfoNvidia(device)
|
31
|
+
core_map[device.device_id] = cores
|
32
|
+
for device in gpu_devices:
|
33
|
+
core = core_map.get(device.device_id, 0)
|
34
|
+
if core == 0:
|
35
|
+
core_print = ""
|
36
|
+
else:
|
37
|
+
core_print = f"({core} Cores)"
|
22
38
|
if device.subsystem_device_name != "":
|
23
|
-
device_name = f"{device.vendor_name} {device.device_name}
|
39
|
+
device_name = f"{device.vendor_name} {device.device_name} [{device.subsystem_device_name}] {core_print}"
|
24
40
|
else:
|
25
|
-
device_name = f"{device.vendor_name} {device.device_name}"
|
41
|
+
device_name = f"{device.vendor_name} {device.device_name} {core_print}"
|
26
42
|
self.__gpuInfo.gpus.append(self.__gpuNameClean(device_name))
|
27
43
|
self.__gpuInfo.number += 1
|
28
44
|
|
45
|
+
def __getGPUInfoNvidia(self, device):
|
46
|
+
try:
|
47
|
+
package_root = Path(__file__).resolve().parent.parent.parent
|
48
|
+
lib = ctypes.CDLL(f"{package_root}/library/lib/nvmlGPULib_{self.__arch}.so")
|
49
|
+
lib.GetGPUCoreCountByPciBusId.argtypes = [ctypes.c_char_p]
|
50
|
+
lib.GetGPUCoreCountByPciBusId.restype = ctypes.c_uint
|
51
|
+
cores = lib.GetGPUCoreCountByPciBusId(f'00000000:{device.bus}'.encode())
|
52
|
+
return cores
|
53
|
+
except Exception as e:
|
54
|
+
# print(f"An error occurred while getting GPU info using nvml: {e}")
|
55
|
+
return 0
|
56
|
+
|
29
57
|
def __handleNonePciDevices(self):
|
30
58
|
# if detector can't find any VGA/Display/3D GPUs, assume the host is a sbc device, this function is a placeholder for a more advanced method.
|
31
59
|
if getArch() in ["aarch64", "arm32", "riscv64"]:
|
@@ -40,5 +68,13 @@ class GPUDetectLinux:
|
|
40
68
|
gpu_name_clean = gpu_name.replace("Corporation ", "")
|
41
69
|
return gpu_name_clean
|
42
70
|
|
71
|
+
@staticmethod
|
72
|
+
def __setArch():
|
73
|
+
arch = getArch()
|
74
|
+
if arch == "aarch64":
|
75
|
+
return "arm64"
|
76
|
+
elif arch == "x86_64":
|
77
|
+
return "amd64"
|
78
|
+
|
43
79
|
def __sortGPUList(self):
|
44
80
|
self.__gpuInfo.gpus.sort()
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import ctypes
|
2
|
+
import pypci
|
3
|
+
|
4
|
+
|
5
|
+
def main():
|
6
|
+
lib = ctypes.CDLL(f"../lib/nvmlGPULib_amd64.so")
|
7
|
+
lib.GetGPUCoreCount.argtypes = [ctypes.c_uint]
|
8
|
+
lib.GetGPUCoreCount.restype = ctypes.c_uint
|
9
|
+
cuda_cores = lib.GetGPUCoreCount(0)
|
10
|
+
print("CUDA Cores:", cuda_cores)
|
11
|
+
lib.GetGPUCoreCountByPciBusId.argtypes = [ctypes.c_char_p]
|
12
|
+
lib.GetGPUCoreCountByPciBusId.restype = ctypes.c_uint
|
13
|
+
pci_bus_id = b"00000000:99:00.0"
|
14
|
+
cuda_cores = lib.GetGPUCoreCountByPciBusId(pci_bus_id)
|
15
|
+
print("CUDA Cores by PCI Bus ID:", cuda_cores)
|
16
|
+
|
17
|
+
gpu_devices = pypci.PCI().FindAllVGA()
|
18
|
+
for gpu in gpu_devices:
|
19
|
+
print(f"id: {gpu.bus}")
|
20
|
+
print(f"cuda cores: {lib.GetGPUCoreCountByPciBusId(f'00000000:{gpu.bus}'.encode())}")
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
if __name__ == "__main__":
|
25
|
+
main()
|
pyhw/pyhwUtil/pyhwUtil.py
CHANGED
@@ -26,7 +26,7 @@ def getOS():
|
|
26
26
|
def getArch():
|
27
27
|
"""
|
28
28
|
Get the machine architecture.
|
29
|
-
:return: str, value in [x86_64, x86, aarch64, arm32, riscv64].
|
29
|
+
:return: str, value in [x86_64, x86, aarch64, arm32, riscv64, s390x, ppc64le].
|
30
30
|
"""
|
31
31
|
arch = platform.machine()
|
32
32
|
if arch == "x86_64" or arch == "AMD64" or arch == "amd64":
|
@@ -39,6 +39,10 @@ def getArch():
|
|
39
39
|
return "arm32"
|
40
40
|
elif arch == "riscv64":
|
41
41
|
return "riscv64"
|
42
|
+
elif arch == "s390x":
|
43
|
+
return "s390x"
|
44
|
+
elif arch == "ppc64le":
|
45
|
+
return "ppc64le"
|
42
46
|
else:
|
43
47
|
return "unknown"
|
44
48
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pyhw
|
3
|
-
Version: 0.12.
|
3
|
+
Version: 0.12.5
|
4
4
|
Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
|
5
5
|
Author: Xiao Ran
|
6
6
|
Maintainer-email: Xiao Ran <xiaoran.007@icloud.com>
|
@@ -33,7 +33,7 @@ Dynamic: license-file
|
|
33
33
|

|
34
34
|
|
35
35
|
|
36
|
-
PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python.
|
36
|
+
PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python.
|
37
37
|
|
38
38
|
This project is a Python reimplementation of [neofetch](https://github.com/dylanaraps/neofetch) and references the [fastfetch](https://github.com/fastfetch-cli/fastfetch) project for logo style settings. Since this project is implemented in Python, it will be easier to maintain and extend than bash and c implementation. Also, this project only relies on the Python standard library, so you can run it on any device that has a Python environment (I hope so 🤔).
|
39
39
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
pyhw/__init__.py,sha256=
|
1
|
+
pyhw/__init__.py,sha256=faUs0tNZKI8zIxX-HDS9VUhJDeK8pDVQnHIopYeWQJA,49
|
2
2
|
pyhw/__main__.py,sha256=oZpFtvSyYTM8cMsulvi51zJV0gtmw3OCQVdgoaHbtxc,4977
|
3
3
|
pyhw/backend/__init__.py,sha256=X1D1D28lSojDrUzUolgJvmbuctwBh_UxG3FwUeL8adA,51
|
4
4
|
pyhw/backend/backendBase.py,sha256=mloo8mPEbgbIdmyQ3I4vdEXMSSjxWi_wnwACmzvHbEo,506
|
@@ -13,7 +13,7 @@ pyhw/backend/gpu/__init__.py,sha256=EpMjPvUaXt0LTNMvGmB8WgXbUB9keCxuOhu8NT3Re6o,
|
|
13
13
|
pyhw/backend/gpu/bsd.py,sha256=ladMMIlTwb6Z1ETCLFII--lkeLCp50Wb7WFrlOXa5DQ,123
|
14
14
|
pyhw/backend/gpu/gpuBase.py,sha256=ZPT9o7PhYpzlwign0GsCT519F9DGx-1UEMVVOM8MV_k,748
|
15
15
|
pyhw/backend/gpu/gpuInfo.py,sha256=d_z_z5DiZAg85wP0VOBQEU0QHdaK3qFqA2Tp9Eq8-Zs,133
|
16
|
-
pyhw/backend/gpu/linux.py,sha256=
|
16
|
+
pyhw/backend/gpu/linux.py,sha256=DQMayZINcQLJe4_Gm_SYWhG8gL1T0YcyP97TfEwYVis,3010
|
17
17
|
pyhw/backend/gpu/macos.py,sha256=s-GZk_Q7K58nSOYuOIAYLRvLafwHyQtsWrPVe3CuXac,4068
|
18
18
|
pyhw/backend/gpu/windows.py,sha256=9VlObAdcOXJyFFxHKHSnFdL07xiGZHNHwn6C843TfNg,1170
|
19
19
|
pyhw/backend/host/__init__.py,sha256=Efaj7-Oya7H8HdpZHQCLrwn-mcfPb-d6yfh4dzsE_7I,58
|
@@ -103,18 +103,22 @@ pyhw/frontend/logo/ascii/windows_10.pyhw,sha256=jv5pzZs_CdOzpeTjyXfXJWcTQwK-J0LN
|
|
103
103
|
pyhw/frontend/logo/ascii/windows_11.pyhw,sha256=VuQTzbBabaEQhm2JBVhy6Ja6lClUGacQsaiNUih9nhU,656
|
104
104
|
pyhw/frontend/logo/ascii/windows_2025.pyhw,sha256=o8eWsiyhNpDoEjiWFiBMfkd-8MdIslGc1Jpm85LU4P8,643
|
105
105
|
pyhw/frontend/logo/ascii/windows_old.pyhw,sha256=AMsvWAZ50HM8lweWEmzDWbRNDGkKFJo9qLY_VRKrciY,580
|
106
|
-
pyhw/library/lib/
|
107
|
-
pyhw/library/lib/
|
106
|
+
pyhw/library/lib/iokitCPULib.dylib,sha256=gLi_HpkmNrzfOnyDxtzzmy65PxlC56g2LcS1l056PHQ,173320
|
107
|
+
pyhw/library/lib/iokitGPULib.dylib,sha256=1YWsob0FBmzQSX0cktW_m1kPuU8dpHoZOu_FTyVuISk,155224
|
108
|
+
pyhw/library/lib/iokitHostLib.dylib,sha256=5ODiCEjoQwVppGmpen9nPGKGqXE9ntohyTUHZkT8viE,149912
|
109
|
+
pyhw/library/lib/nvmlGPULib_amd64.so,sha256=lrkxeJjChUs8oVhaw_uMeXKbUJp24KroQ_hhcLtHfTg,12784
|
110
|
+
pyhw/library/lib/nvmlGPULib_arm64.so,sha256=DFIYqNcuRxiZ8_jrYoaRB3Dx9GrY7UBXscwXQvV4k3I,13528
|
108
111
|
pyhw/library/test/iokitHostLibTest.py,sha256=oz5x1g4WMdoikU3Eo6zoxcHZ4e-UMRhXg0C0Lflo-ac,272
|
112
|
+
pyhw/library/test/nvmlGPULibTest.py,sha256=F4AjQGZDNj29fRtxvy41zCSFi2Eirp0CQSYuxuw0n60,785
|
109
113
|
pyhw/pyhwException/__init__.py,sha256=juw4PdgPa-eLy0y678BQ7_Ck-BJa-P0LHyKCGePazb8,221
|
110
114
|
pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1GVTFVa0,197
|
111
115
|
pyhw/pyhwUtil/__init__.py,sha256=n3jWo-q-jSouXvUHMg45DOHS5xLRG64E02A9rDQb44M,323
|
112
116
|
pyhw/pyhwUtil/cliUtil.py,sha256=_zNrhzQvrtqUp6xyZ0JTs_KyL1wvLji-nBmU65XA1aI,2342
|
113
|
-
pyhw/pyhwUtil/pyhwUtil.py,sha256=
|
117
|
+
pyhw/pyhwUtil/pyhwUtil.py,sha256=_eUOHcuUqPHYuecDf0nEdF2GRuRJhW99MqYSJyZ4KUA,8270
|
114
118
|
pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
|
115
|
-
pyhw-0.12.
|
116
|
-
pyhw-0.12.
|
117
|
-
pyhw-0.12.
|
118
|
-
pyhw-0.12.
|
119
|
-
pyhw-0.12.
|
120
|
-
pyhw-0.12.
|
119
|
+
pyhw-0.12.5.dist-info/licenses/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
|
120
|
+
pyhw-0.12.5.dist-info/METADATA,sha256=MHtvwKQ2cyBZ648vAVq6QmbCt4tbfUIiCeKqHvEzFVI,6780
|
121
|
+
pyhw-0.12.5.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
122
|
+
pyhw-0.12.5.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
|
123
|
+
pyhw-0.12.5.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
|
124
|
+
pyhw-0.12.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|