pyhw 0.2.0b0__tar.gz → 0.7.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- pyhw-0.7.3/PKG-INFO +131 -0
- pyhw-0.7.3/README.md +114 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/pyproject.toml +7 -2
- pyhw-0.7.3/src/pyhw/__init__.py +1 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/__main__.py +10 -3
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/backendBase.py +2 -0
- pyhw-0.7.3/src/pyhw/backend/cpu/bsd.py +12 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/cpuBase.py +3 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/linux.py +26 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/macos.py +3 -1
- pyhw-0.7.3/src/pyhw/backend/gpu/bsd.py +7 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/gpu/gpuBase.py +3 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/gpu/linux.py +20 -11
- pyhw-0.7.3/src/pyhw/backend/gpu/macos.py +100 -0
- pyhw-0.7.3/src/pyhw/backend/host/bsd.py +13 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/host/hostBase.py +3 -0
- pyhw-0.7.3/src/pyhw/backend/host/linux.py +65 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/host/macos.py +11 -1
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/kernelBase.py +1 -3
- pyhw-0.7.3/src/pyhw/backend/memory/bsd.py +11 -0
- pyhw-0.7.3/src/pyhw/backend/memory/linux.py +24 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/memory/memoryBase.py +3 -0
- pyhw-0.7.3/src/pyhw/backend/nic/__init__.py +4 -0
- pyhw-0.7.3/src/pyhw/backend/nic/bsd.py +7 -0
- pyhw-0.7.3/src/pyhw/backend/nic/linux.py +41 -0
- pyhw-0.7.3/src/pyhw/backend/nic/macos.py +27 -0
- pyhw-0.7.3/src/pyhw/backend/nic/nicBase.py +25 -0
- pyhw-0.7.3/src/pyhw/backend/nic/nicInfo.py +8 -0
- pyhw-0.7.3/src/pyhw/backend/npu/__init__.py +5 -0
- pyhw-0.7.3/src/pyhw/backend/npu/bsd.py +6 -0
- pyhw-0.7.3/src/pyhw/backend/npu/linux.py +38 -0
- pyhw-0.7.3/src/pyhw/backend/npu/macos.py +65 -0
- pyhw-0.7.3/src/pyhw/backend/npu/npuBase.py +20 -0
- pyhw-0.7.3/src/pyhw/backend/npu/npuInfo.py +10 -0
- pyhw-0.7.3/src/pyhw/backend/os/bsd.py +7 -0
- pyhw-0.7.3/src/pyhw/backend/os/linux.py +52 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/os/macos.py +21 -3
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/os/osBase.py +3 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/shell/shellBase.py +1 -1
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/shell/unix.py +20 -2
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/title/titleBase.py +1 -1
- pyhw-0.7.3/src/pyhw/backend/uptime/bsd.py +7 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/macos.py +12 -12
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/uptimeBase.py +3 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/color/colorConfig.py +70 -1
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/frontendBase.py +41 -2
- pyhw-0.7.3/src/pyhw/frontend/logo/ascii/alpine.pyhw +6 -0
- pyhw-0.7.3/src/pyhw/frontend/logo/ascii/arch.pyhw +19 -0
- pyhw-0.7.3/src/pyhw/frontend/logo/ascii/armbian.pyhw +14 -0
- pyhw-0.7.3/src/pyhw/frontend/logo/ascii/centos.pyhw +19 -0
- pyhw-0.7.3/src/pyhw/frontend/logo/ascii/freebsd.pyhw +15 -0
- pyhw-0.7.3/src/pyhw/frontend/logo/ascii/raspbian.pyhw +10 -0
- pyhw-0.7.3/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
- pyhw-0.7.3/src/pyhw/library/lib/iokitHostLib.dylib +0 -0
- pyhw-0.7.3/src/pyhw/pyhwUtil/__init__.py +4 -0
- pyhw-0.7.3/src/pyhw/pyhwUtil/pyhwUtil.py +207 -0
- pyhw-0.7.3/src/pyhw.egg-info/PKG-INFO +131 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw.egg-info/SOURCES.txt +27 -2
- pyhw-0.7.3/src/pyhw.egg-info/requires.txt +1 -0
- pyhw-0.2.0b0/MANIFEST.in +0 -1
- pyhw-0.2.0b0/PKG-INFO +0 -50
- pyhw-0.2.0b0/README.md +0 -36
- pyhw-0.2.0b0/src/pyhw/__init__.py +0 -1
- pyhw-0.2.0b0/src/pyhw/backend/gpu/macos.py +0 -63
- pyhw-0.2.0b0/src/pyhw/backend/host/linux.py +0 -38
- pyhw-0.2.0b0/src/pyhw/backend/memory/linux.py +0 -24
- pyhw-0.2.0b0/src/pyhw/backend/os/linux.py +0 -47
- pyhw-0.2.0b0/src/pyhw/macos.py +0 -146
- pyhw-0.2.0b0/src/pyhw/pyhwUtil/__init__.py +0 -4
- pyhw-0.2.0b0/src/pyhw/pyhwUtil/pyhwUtil.py +0 -74
- pyhw-0.2.0b0/src/pyhw.egg-info/PKG-INFO +0 -50
- {pyhw-0.2.0b0 → pyhw-0.7.3}/LICENSE +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/setup.cfg +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/host/hostInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/host/windows.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/kernelInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/unix.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/windows.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/memory/macos.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/memory/memoryInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/os/osInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/title/unix.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/title/windows.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/linux.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.2.0b0 → pyhw-0.7.3}/src/pyhw.egg-info/top_level.txt +0 -0
pyhw-0.7.3/PKG-INFO
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: pyhw
|
3
|
+
Version: 0.7.3
|
4
|
+
Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
|
5
|
+
Author-email: Xiao Ran <xiaoran.007@icloud.com>
|
6
|
+
License: BSD-3-Clause
|
7
|
+
Project-URL: homepage, https://github.com/xiaoran007/pyhw
|
8
|
+
Keywords: neofetch,system information,command line tool,python,hardware information,fastfetch,fetching
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: License :: OSI Approved :: BSD License
|
12
|
+
Classifier: Operating System :: OS Independent
|
13
|
+
Requires-Python: >=3.9
|
14
|
+
Description-Content-Type: text/markdown
|
15
|
+
License-File: LICENSE
|
16
|
+
Requires-Dist: pypci-ng>=0.0.10
|
17
|
+
|
18
|
+
# PyHw
|
19
|
+
[](https://pepy.tech/project/pyhw)
|
20
|
+

|
21
|
+
|
22
|
+

|
23
|
+

|
24
|
+

|
25
|
+
|
26
|
+

|
27
|
+

|
28
|
+
|
29
|
+
|
30
|
+
PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, and FreeBSD are supported.**
|
31
|
+
|
32
|
+
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 🤔).
|
33
|
+
|
34
|
+
|
35
|
+
[//]: # ()
|
36
|
+

|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
## Install
|
43
|
+
There are already a lot of similar tools so you can choose any of them; they're all essentially no different. If you want to try this tool, just install it directly by pip.
|
44
|
+
```shell
|
45
|
+
pip install pyhw
|
46
|
+
```
|
47
|
+
To upgrade pyhw:
|
48
|
+
```shell
|
49
|
+
pip install pyhw -U
|
50
|
+
# or
|
51
|
+
pip install pyhw --upgrade
|
52
|
+
```
|
53
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
54
|
+
```shell
|
55
|
+
pyhw
|
56
|
+
# or
|
57
|
+
python -m pyhw
|
58
|
+
```
|
59
|
+
Please note that the command line entry for __pyhw__ is created by pip, and depending on the user, this entry may not in the __system PATH__. If you encounter this problem, pip will give you a prompt, follow the prompts to add entry to the __system PATH__.
|
60
|
+
|
61
|
+
### Install by pipx
|
62
|
+
**pipx** is an amazing tool to help you install and run applications written in Python. It is more like **brew** or **apt**. You can find more information about it here [pipx](https://github.com/pypa/pipx).
|
63
|
+
|
64
|
+
You can install pyhw by the following command:
|
65
|
+
```shell
|
66
|
+
pipx install pyhw
|
67
|
+
```
|
68
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
69
|
+
```shell
|
70
|
+
pyhw
|
71
|
+
```
|
72
|
+
|
73
|
+
### Important note about debian 12:
|
74
|
+
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
|
75
|
+
```text
|
76
|
+
error: externally-managed-environment
|
77
|
+
|
78
|
+
× This environment is externally managed
|
79
|
+
╰─> To install Python packages system-wide, try apt install
|
80
|
+
python3-xyz, where xyz is the package you are trying to
|
81
|
+
install.
|
82
|
+
|
83
|
+
If you wish to install a non-Debian-packaged Python package,
|
84
|
+
create a virtual environment using python3 -m venv path/to/venv.
|
85
|
+
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
|
86
|
+
sure you have python3-full installed.
|
87
|
+
|
88
|
+
For more information visit http://rptl.io/venv
|
89
|
+
|
90
|
+
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
|
91
|
+
hint: See PEP 668 for the detailed specification.
|
92
|
+
```
|
93
|
+
This is due to the fact that system python is not supposed to be managed by pip. You can simply use **pipx** to install **pyhw**. Or you can use a virtual environment (venv) or force remove this restriction (not recommended).
|
94
|
+
|
95
|
+
## Tested OS
|
96
|
+
* macOS arm64, x86_64
|
97
|
+
* Linux arm64, x86_64
|
98
|
+
* FreeBSD arm64
|
99
|
+
|
100
|
+
|
101
|
+
## Build from source
|
102
|
+
Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a Mac machine with macOS 11 and newer.
|
103
|
+
|
104
|
+
### Dependencies
|
105
|
+
This package was originally implemented in pure python and only depends on the python standard library. However, in subsequent development, the code for the pci part was separated into a separate package **pypci-ng**, which can be obtained using pip (or check out [this](https://github.com/xiaoran007/pypci) GitHub repository).
|
106
|
+
|
107
|
+
### Build tools
|
108
|
+
Make sure the following Python build tools are already installed.
|
109
|
+
* setuptools
|
110
|
+
* build
|
111
|
+
* twine
|
112
|
+
|
113
|
+
### Build package
|
114
|
+
clone the project, and run:
|
115
|
+
```shell
|
116
|
+
python -m build
|
117
|
+
```
|
118
|
+
After the build process, the source package and the binary whl package can be found in the dist folder. Then you can use the following command to install the new package.
|
119
|
+
```shell
|
120
|
+
pip install dist/*.whl --force-reinstall
|
121
|
+
```
|
122
|
+
Or simply type:
|
123
|
+
```shell
|
124
|
+
make build
|
125
|
+
make install
|
126
|
+
```
|
127
|
+
If you have docker installed, you can test this package through docker by type:
|
128
|
+
```shell
|
129
|
+
make test # local build
|
130
|
+
make test-pypi # release version
|
131
|
+
```
|
pyhw-0.7.3/README.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# PyHw
|
2
|
+
[](https://pepy.tech/project/pyhw)
|
3
|
+

|
4
|
+
|
5
|
+

|
6
|
+

|
7
|
+

|
8
|
+
|
9
|
+

|
10
|
+

|
11
|
+
|
12
|
+
|
13
|
+
PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, and FreeBSD are supported.**
|
14
|
+
|
15
|
+
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 🤔).
|
16
|
+
|
17
|
+
|
18
|
+
[//]: # ()
|
19
|
+

|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## Install
|
26
|
+
There are already a lot of similar tools so you can choose any of them; they're all essentially no different. If you want to try this tool, just install it directly by pip.
|
27
|
+
```shell
|
28
|
+
pip install pyhw
|
29
|
+
```
|
30
|
+
To upgrade pyhw:
|
31
|
+
```shell
|
32
|
+
pip install pyhw -U
|
33
|
+
# or
|
34
|
+
pip install pyhw --upgrade
|
35
|
+
```
|
36
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
37
|
+
```shell
|
38
|
+
pyhw
|
39
|
+
# or
|
40
|
+
python -m pyhw
|
41
|
+
```
|
42
|
+
Please note that the command line entry for __pyhw__ is created by pip, and depending on the user, this entry may not in the __system PATH__. If you encounter this problem, pip will give you a prompt, follow the prompts to add entry to the __system PATH__.
|
43
|
+
|
44
|
+
### Install by pipx
|
45
|
+
**pipx** is an amazing tool to help you install and run applications written in Python. It is more like **brew** or **apt**. You can find more information about it here [pipx](https://github.com/pypa/pipx).
|
46
|
+
|
47
|
+
You can install pyhw by the following command:
|
48
|
+
```shell
|
49
|
+
pipx install pyhw
|
50
|
+
```
|
51
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
52
|
+
```shell
|
53
|
+
pyhw
|
54
|
+
```
|
55
|
+
|
56
|
+
### Important note about debian 12:
|
57
|
+
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
|
58
|
+
```text
|
59
|
+
error: externally-managed-environment
|
60
|
+
|
61
|
+
× This environment is externally managed
|
62
|
+
╰─> To install Python packages system-wide, try apt install
|
63
|
+
python3-xyz, where xyz is the package you are trying to
|
64
|
+
install.
|
65
|
+
|
66
|
+
If you wish to install a non-Debian-packaged Python package,
|
67
|
+
create a virtual environment using python3 -m venv path/to/venv.
|
68
|
+
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
|
69
|
+
sure you have python3-full installed.
|
70
|
+
|
71
|
+
For more information visit http://rptl.io/venv
|
72
|
+
|
73
|
+
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
|
74
|
+
hint: See PEP 668 for the detailed specification.
|
75
|
+
```
|
76
|
+
This is due to the fact that system python is not supposed to be managed by pip. You can simply use **pipx** to install **pyhw**. Or you can use a virtual environment (venv) or force remove this restriction (not recommended).
|
77
|
+
|
78
|
+
## Tested OS
|
79
|
+
* macOS arm64, x86_64
|
80
|
+
* Linux arm64, x86_64
|
81
|
+
* FreeBSD arm64
|
82
|
+
|
83
|
+
|
84
|
+
## Build from source
|
85
|
+
Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a Mac machine with macOS 11 and newer.
|
86
|
+
|
87
|
+
### Dependencies
|
88
|
+
This package was originally implemented in pure python and only depends on the python standard library. However, in subsequent development, the code for the pci part was separated into a separate package **pypci-ng**, which can be obtained using pip (or check out [this](https://github.com/xiaoran007/pypci) GitHub repository).
|
89
|
+
|
90
|
+
### Build tools
|
91
|
+
Make sure the following Python build tools are already installed.
|
92
|
+
* setuptools
|
93
|
+
* build
|
94
|
+
* twine
|
95
|
+
|
96
|
+
### Build package
|
97
|
+
clone the project, and run:
|
98
|
+
```shell
|
99
|
+
python -m build
|
100
|
+
```
|
101
|
+
After the build process, the source package and the binary whl package can be found in the dist folder. Then you can use the following command to install the new package.
|
102
|
+
```shell
|
103
|
+
pip install dist/*.whl --force-reinstall
|
104
|
+
```
|
105
|
+
Or simply type:
|
106
|
+
```shell
|
107
|
+
make build
|
108
|
+
make install
|
109
|
+
```
|
110
|
+
If you have docker installed, you can test this package through docker by type:
|
111
|
+
```shell
|
112
|
+
make test # local build
|
113
|
+
make test-pypi # release version
|
114
|
+
```
|
@@ -4,15 +4,20 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "pyhw"
|
7
|
-
version = "0.
|
7
|
+
version = "0.7.3"
|
8
8
|
description = "PyHw, a neofetch-like command line tool for fetching system information but written mostly in python."
|
9
|
+
keywords = ["neofetch", "system information", "command line tool", "python", "hardware information", "fastfetch", "fetching"]
|
9
10
|
authors = [
|
10
11
|
{ name = "Xiao Ran", email = "xiaoran.007@icloud.com" }
|
11
12
|
]
|
12
13
|
readme = "README.md"
|
13
14
|
license = {text = "BSD-3-Clause"}
|
14
15
|
requires-python = ">=3.9"
|
16
|
+
dependencies = [
|
17
|
+
"pypci-ng>=0.0.10"
|
18
|
+
]
|
15
19
|
classifiers = [
|
20
|
+
"Development Status :: 4 - Beta",
|
16
21
|
"Programming Language :: Python :: 3",
|
17
22
|
"License :: OSI Approved :: BSD License",
|
18
23
|
"Operating System :: OS Independent"
|
@@ -25,7 +30,7 @@ package-dir = {"" = "src"}
|
|
25
30
|
include-package-data = true
|
26
31
|
|
27
32
|
[tool.setuptools.package-data]
|
28
|
-
"pyhw" = ["frontend/logo/ascii/*.pyhw"]
|
33
|
+
"pyhw" = ["frontend/logo/ascii/*.pyhw", "library/lib/*.dylib"]
|
29
34
|
|
30
35
|
[project.scripts]
|
31
36
|
pyhw = "pyhw.__main__:main"
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = '0.7.3'
|
@@ -9,15 +9,16 @@ from .backend.os import OSDetect
|
|
9
9
|
from .backend.cpu import CPUDetect
|
10
10
|
from .backend.gpu import GPUDetect
|
11
11
|
from .backend.memory import MemoryDetect
|
12
|
+
from .backend.nic import NICDetect
|
13
|
+
from .backend.npu import NPUDetect
|
12
14
|
from .pyhwUtil import createDataString
|
13
15
|
from .pyhwUtil import getOS, selectOSLogo
|
14
16
|
|
15
17
|
|
16
18
|
def main():
|
17
19
|
current_os = getOS()
|
18
|
-
|
19
|
-
|
20
|
-
print(f"Only Linux and macOS is supported for now. Current os: {current_os}")
|
20
|
+
if current_os not in ["linux", "macos", "freebsd"]:
|
21
|
+
print(f"Only Linux, macOS, and FreeBSD is supported for now. Current os: {current_os}")
|
21
22
|
return
|
22
23
|
data = Data()
|
23
24
|
data.title = TitleDetect(os=current_os).getTitle().title
|
@@ -31,6 +32,12 @@ def main():
|
|
31
32
|
if gpu_info.number > 0:
|
32
33
|
data.GPU = gpu_info.gpus
|
33
34
|
data.Memory = MemoryDetect(os=current_os).getMemoryInfo().memory
|
35
|
+
nic_info = NICDetect(os=current_os).getNICInfo()
|
36
|
+
if nic_info.number > 0:
|
37
|
+
data.NIC = nic_info.nics
|
38
|
+
npu_info = NPUDetect(os=current_os).getNPUInfo()
|
39
|
+
if npu_info.number > 0:
|
40
|
+
data.NPU = npu_info.npus
|
34
41
|
|
35
42
|
Printer(logo_os=selectOSLogo(OSDetect(os=current_os).getOSInfo().id), data=createDataString(data)).cPrint()
|
36
43
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from .cpuInfo import CPUInfo
|
2
|
+
from ...pyhwUtil import sysctlGetString, sysctlGetInt, getArch
|
3
|
+
|
4
|
+
|
5
|
+
class CPUDetectBSD:
|
6
|
+
def __init__(self):
|
7
|
+
self.__cpuInfo = CPUInfo()
|
8
|
+
|
9
|
+
def getCPUInfo(self):
|
10
|
+
self.__cpuInfo.cpu = sysctlGetString("hw.model")
|
11
|
+
return self.__cpuInfo
|
12
|
+
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import CPUDetectLinux
|
2
2
|
from .macos import CPUDetectMacOS
|
3
|
+
from .bsd import CPUDetectBSD
|
3
4
|
from ...pyhwException import OSUnsupportedException
|
4
5
|
|
5
6
|
|
@@ -12,5 +13,7 @@ class CPUDetect:
|
|
12
13
|
return CPUDetectLinux().getCPUInfo()
|
13
14
|
elif self.OS == "macos":
|
14
15
|
return CPUDetectMacOS().getCPUInfo()
|
16
|
+
elif self.OS == "freebsd":
|
17
|
+
return CPUDetectBSD().getCPUInfo()
|
15
18
|
else:
|
16
19
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -10,6 +10,9 @@ class CPUDetectLinux:
|
|
10
10
|
def getCPUInfo(self):
|
11
11
|
self.__getCPUInfo()
|
12
12
|
self.__modelClean()
|
13
|
+
self.__handleSBC()
|
14
|
+
if self.__cpuInfo.model == "":
|
15
|
+
self.__cpuInfo.model = "Unknown"
|
13
16
|
if self.__cpuInfo.model != "":
|
14
17
|
self.__cpuInfo.cpu = self.__cpuInfo.model
|
15
18
|
if self.__cpuInfo.cores != "":
|
@@ -51,3 +54,26 @@ class CPUDetectLinux:
|
|
51
54
|
def __modelClean(self):
|
52
55
|
self.__cpuInfo.model = self.__cpuInfo.model.replace("(R)", "")
|
53
56
|
self.__cpuInfo.model = self.__cpuInfo.model.replace("(TM)", "")
|
57
|
+
|
58
|
+
def __handleSBC(self):
|
59
|
+
# some values should be double-checked
|
60
|
+
# Info source: https://github.com/raspberrypi/firmware/tree/master/boot
|
61
|
+
if os.path.exists("/sys/firmware/devicetree/base/compatible"):
|
62
|
+
try:
|
63
|
+
with open("/sys/firmware/devicetree/base/compatible", "r") as f:
|
64
|
+
compatible = f.read().strip()
|
65
|
+
except FileNotFoundError:
|
66
|
+
compatible = ""
|
67
|
+
if "raspberrypi" in compatible:
|
68
|
+
model = compatible.split(",")[-1]
|
69
|
+
if model.startswith("bcm"):
|
70
|
+
self.__cpuInfo.model = model.upper()
|
71
|
+
elif "orangepi" in compatible:
|
72
|
+
if "allwinner" in compatible:
|
73
|
+
model = compatible.split(",")[-1]
|
74
|
+
if model.startswith("sun"):
|
75
|
+
self.__cpuInfo.model = f"Allwinner {model.split('-')[-1].upper()} ({model})"
|
76
|
+
else:
|
77
|
+
pass
|
78
|
+
|
79
|
+
|
@@ -64,6 +64,8 @@ class CPUDetectMacOS:
|
|
64
64
|
"Apple M3": "4.05 GHz",
|
65
65
|
"Apple M3 Pro": "4.05 GHz",
|
66
66
|
"Apple M3 Max": "4.05 GHz",
|
67
|
-
"Apple M4": "4.40 GHz"
|
67
|
+
"Apple M4": "4.40 GHz",
|
68
|
+
"Apple M4 Pro": "4.40 GHz",
|
69
|
+
"Apple M4 Max": "4.40 GHz"
|
68
70
|
}
|
69
71
|
self.__cpuInfo.frequency = freq.get(self.__cpuInfo.model, "Unknown")
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import GPUDetectLinux
|
2
2
|
from .macos import GPUDetectMacOS
|
3
|
+
from .bsd import GPUDetectBSD
|
3
4
|
|
4
5
|
|
5
6
|
class GPUDetect:
|
@@ -11,5 +12,7 @@ class GPUDetect:
|
|
11
12
|
return GPUDetectLinux().getGPUInfo()
|
12
13
|
elif self.OS == "macos":
|
13
14
|
return GPUDetectMacOS().getGPUInfo()
|
15
|
+
elif self.OS == "freebsd":
|
16
|
+
return GPUDetectBSD().getGPUInfo()
|
14
17
|
else:
|
15
18
|
raise NotImplementedError("Unsupported operating system")
|
@@ -2,6 +2,7 @@ import subprocess
|
|
2
2
|
from .gpuInfo import GPUInfo
|
3
3
|
from ..cpu import CPUDetect
|
4
4
|
from ...pyhwUtil import getArch
|
5
|
+
import pypci
|
5
6
|
|
6
7
|
|
7
8
|
class GPUDetectLinux:
|
@@ -10,22 +11,21 @@ class GPUDetectLinux:
|
|
10
11
|
|
11
12
|
def getGPUInfo(self):
|
12
13
|
self.__getGPUInfo()
|
14
|
+
self.__sortGPUList()
|
13
15
|
return self.__gpuInfo
|
14
16
|
|
15
17
|
def __getGPUInfo(self):
|
16
|
-
|
17
|
-
|
18
|
-
except subprocess.SubprocessError:
|
19
|
-
return
|
20
|
-
if len(pci_info) == 0: # no pcie devices found
|
18
|
+
gpu_devices = pypci.PCI().FindAllVGA()
|
19
|
+
if len(gpu_devices) == 0:
|
21
20
|
self.__handleNonePciDevices()
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
else:
|
22
|
+
for device in gpu_devices:
|
23
|
+
if device.subsystem_device_name != "":
|
24
|
+
device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
|
25
|
+
else:
|
26
|
+
device_name = f"{device.vendor_name} {device.device_name}"
|
27
|
+
self.__gpuInfo.gpus.append(self.__gpuNameClean(device_name))
|
26
28
|
self.__gpuInfo.number += 1
|
27
|
-
if self.__gpuInfo.number == 0:
|
28
|
-
self.__handleNonePciDevices() # fallback to a sbc device detection method
|
29
29
|
|
30
30
|
def __handleNonePciDevices(self):
|
31
31
|
# 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.
|
@@ -35,3 +35,12 @@ class GPUDetectLinux:
|
|
35
35
|
else:
|
36
36
|
self.__gpuInfo.number = 1
|
37
37
|
self.__gpuInfo.gpus.append("Not found")
|
38
|
+
|
39
|
+
@staticmethod
|
40
|
+
def __gpuNameClean(gpu_name: str):
|
41
|
+
gpu_name_clean = gpu_name.replace("Corporation ", "")
|
42
|
+
return gpu_name_clean
|
43
|
+
|
44
|
+
def __sortGPUList(self):
|
45
|
+
self.__gpuInfo.gpus.sort()
|
46
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
from .gpuInfo import GPUInfo
|
2
|
+
from ...pyhwUtil import getArch
|
3
|
+
import json
|
4
|
+
import subprocess
|
5
|
+
import ctypes
|
6
|
+
from pathlib import Path
|
7
|
+
|
8
|
+
|
9
|
+
class GPUDetectMacOS:
|
10
|
+
def __init__(self):
|
11
|
+
self.__gpuInfo = GPUInfo()
|
12
|
+
self.__arch = getArch()
|
13
|
+
|
14
|
+
def getGPUInfo(self):
|
15
|
+
if self.__arch == "aarch64":
|
16
|
+
self.__getGPUAppleSilicon()
|
17
|
+
else: # Does not consider powerPC based Macs.
|
18
|
+
self.__getGPUIntel()
|
19
|
+
return self.__gpuInfo
|
20
|
+
|
21
|
+
def __getGPUAppleSilicon(self):
|
22
|
+
gpus = list()
|
23
|
+
try:
|
24
|
+
gpu_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"]))
|
25
|
+
if 'SPDisplaysDataType' in gpu_info_dict:
|
26
|
+
gpus = gpu_info_dict['SPDisplaysDataType']
|
27
|
+
self.__gpuInfo.number = len(gpus)
|
28
|
+
else:
|
29
|
+
pass
|
30
|
+
except Exception:
|
31
|
+
return
|
32
|
+
|
33
|
+
for gpu in gpus:
|
34
|
+
self.__gpuInfo.gpus.append(f'{gpu.get("sppci_model")} ({gpu.get("sppci_cores")} cores) [SOC Integrated]')
|
35
|
+
|
36
|
+
def __getGPUIntel(self):
|
37
|
+
if self.__getGPUIOKit():
|
38
|
+
pass
|
39
|
+
else: # fallback to the default implementation
|
40
|
+
gpus = list()
|
41
|
+
try:
|
42
|
+
gpu_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"]))
|
43
|
+
if 'SPDisplaysDataType' in gpu_info_dict:
|
44
|
+
gpus = gpu_info_dict['SPDisplaysDataType']
|
45
|
+
self.__gpuInfo.number = len(gpus)
|
46
|
+
else:
|
47
|
+
pass
|
48
|
+
except Exception:
|
49
|
+
return
|
50
|
+
|
51
|
+
for gpu in gpus:
|
52
|
+
if self.__handleVendor(gpu.get("spdisplays_vendor")) == "Intel": # Integrated GPU
|
53
|
+
self.__gpuInfo.gpus.append(f'{gpu.get("sppci_model")} [CPU Integrated]')
|
54
|
+
elif self.__handleVendor(gpu.get("spdisplays_vendor")) == "AMD": # dGPU
|
55
|
+
self.__gpuInfo.gpus.append(f'{gpu.get("sppci_model")} {gpu.get("spdisplays_vram")} [Discrete]')
|
56
|
+
elif self.__handleVendor(gpu.get("spdisplays_vendor")) == "Nvidia": # Since current macOS does not support NVIDIA GPUs, this condition is not applicable
|
57
|
+
pass
|
58
|
+
|
59
|
+
def __getGPUIOKit(self):
|
60
|
+
try:
|
61
|
+
package_root = Path(__file__).resolve().parent.parent.parent
|
62
|
+
lib = ctypes.CDLL(f"{package_root}/library/lib/iokitGPULib.dylib")
|
63
|
+
lib.getGPUInfo.restype = ctypes.c_char_p
|
64
|
+
gpu_info = lib.getGPUInfo()
|
65
|
+
gpus = gpu_info.decode('utf-8').split("; ")
|
66
|
+
self.__gpuInfo.number = len(gpus)
|
67
|
+
for gpu in gpus:
|
68
|
+
info_list = gpu.split(", ")
|
69
|
+
model = info_list[0]
|
70
|
+
vendor_id = info_list[1]
|
71
|
+
vram = round(int(info_list[2]) / 1024, None)
|
72
|
+
if self.__handleVendorID(vendor_id) == "Intel": # Integrated GPU
|
73
|
+
self.__gpuInfo.gpus.append(f'{model} [CPU Integrated]')
|
74
|
+
elif self.__handleVendorID(vendor_id) == "AMD": # dGPU
|
75
|
+
self.__gpuInfo.gpus.append(f'{model} {vram} GB [Discrete]')
|
76
|
+
return True
|
77
|
+
except Exception as e:
|
78
|
+
# print(f"An error occurred while getting GPU info using IOKit: {e}")
|
79
|
+
return False
|
80
|
+
|
81
|
+
@staticmethod
|
82
|
+
def __handleVendor(vendor):
|
83
|
+
if vendor == "sppci_vendor_Apple":
|
84
|
+
return "Apple"
|
85
|
+
elif vendor == "sppci_vendor_intel":
|
86
|
+
return "Intel"
|
87
|
+
elif vendor == "sppci_vendor_amd":
|
88
|
+
return "AMD"
|
89
|
+
else:
|
90
|
+
return vendor
|
91
|
+
|
92
|
+
@staticmethod
|
93
|
+
def __handleVendorID(vendor_id):
|
94
|
+
if vendor_id == "0x8086":
|
95
|
+
return "Intel"
|
96
|
+
elif vendor_id == "0x1002":
|
97
|
+
return "AMD"
|
98
|
+
else:
|
99
|
+
return vendor_id
|
100
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from .linux import HostDetectLinux
|
2
|
+
|
3
|
+
|
4
|
+
class HostDetectBSD(HostDetectLinux):
|
5
|
+
def __init__(self):
|
6
|
+
HostDetectLinux.__init__(self)
|
7
|
+
|
8
|
+
def getHostInfo(self):
|
9
|
+
self._hostInfo.name = f"General {self._arch} FreeBSD Host"
|
10
|
+
self._hostInfo.version = ""
|
11
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
12
|
+
return self._hostInfo
|
13
|
+
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from .linux import HostDetectLinux
|
2
2
|
from .macos import HostDetectMacOS
|
3
3
|
from .windows import HostDetectWindows
|
4
|
+
from .bsd import HostDetectBSD
|
4
5
|
from ...pyhwException import OSUnsupportedException
|
5
6
|
|
6
7
|
|
@@ -13,6 +14,8 @@ class HostDetect:
|
|
13
14
|
return HostDetectLinux().getHostInfo()
|
14
15
|
elif self.OS == "macos":
|
15
16
|
return HostDetectMacOS().getHostInfo()
|
17
|
+
elif self.OS == "freebsd":
|
18
|
+
return HostDetectBSD().getHostInfo()
|
16
19
|
elif self.OS == "windows":
|
17
20
|
pass
|
18
21
|
else:
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"""
|
2
|
+
In dev.
|
3
|
+
"""
|
4
|
+
from ...pyhwUtil import getArch, getDocker
|
5
|
+
from .hostInfo import HostInfo
|
6
|
+
import os
|
7
|
+
|
8
|
+
|
9
|
+
class HostDetectLinux:
|
10
|
+
def __init__(self):
|
11
|
+
self._hostInfo = HostInfo()
|
12
|
+
self._arch = getArch()
|
13
|
+
self._docker = getDocker()
|
14
|
+
|
15
|
+
def getHostInfo(self):
|
16
|
+
self._getModel()
|
17
|
+
return self._hostInfo
|
18
|
+
|
19
|
+
def _getModel(self):
|
20
|
+
if self._docker:
|
21
|
+
self._hostInfo.name = f"General {self._arch} Docker Host"
|
22
|
+
self._hostInfo.version = ""
|
23
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
24
|
+
else:
|
25
|
+
if self._arch in ["x86_64", "x86"]:
|
26
|
+
try:
|
27
|
+
with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
|
28
|
+
product_name = f.read().strip()
|
29
|
+
if product_name.startswith("To be filled by O.E.M."):
|
30
|
+
self._hostInfo.name = f"General {self._arch} Host"
|
31
|
+
else:
|
32
|
+
self._hostInfo.name = product_name
|
33
|
+
with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
|
34
|
+
version = f.read().strip()
|
35
|
+
if version.startswith("To be filled by O.E.M."):
|
36
|
+
self._hostInfo.version = ""
|
37
|
+
else:
|
38
|
+
self._hostInfo.version = version
|
39
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
40
|
+
except FileNotFoundError:
|
41
|
+
pass
|
42
|
+
elif self._arch in ["aarch64", "arm32"]:
|
43
|
+
# try to find dmi folder since some arm based desktops and servers may have same structure as x86_64 machines.
|
44
|
+
if os.path.exists("/sys/devices/virtual/dmi/id"):
|
45
|
+
try:
|
46
|
+
with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
|
47
|
+
self._hostInfo.name = f.read().strip()
|
48
|
+
with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
|
49
|
+
self._hostInfo.version = f.read().strip()
|
50
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
51
|
+
except FileNotFoundError:
|
52
|
+
pass
|
53
|
+
else:
|
54
|
+
# some single board computers may not have dmi folder, try to find model name in device tree.
|
55
|
+
try:
|
56
|
+
with open("/sys/firmware/devicetree/base/model", "r") as f:
|
57
|
+
self._hostInfo.model = f.read().strip()
|
58
|
+
except FileNotFoundError:
|
59
|
+
pass
|
60
|
+
|
61
|
+
def __getHostFamily(self):
|
62
|
+
pass
|
63
|
+
|
64
|
+
def __getHostProductName(self):
|
65
|
+
pass
|