pyhw 0.1.3b0__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.1.3b0 → pyhw-0.7.3}/pyproject.toml +7 -2
- pyhw-0.7.3/src/pyhw/__init__.py +1 -0
- pyhw-0.7.3/src/pyhw/__main__.py +46 -0
- {pyhw-0.1.3b0 → 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.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/cpuBase.py +6 -0
- pyhw-0.7.3/src/pyhw/backend/cpu/cpuInfo.py +13 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/linux.py +29 -11
- pyhw-0.7.3/src/pyhw/backend/cpu/macos.py +71 -0
- pyhw-0.7.3/src/pyhw/backend/gpu/bsd.py +7 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/gpu/gpuBase.py +6 -0
- pyhw-0.7.3/src/pyhw/backend/gpu/gpuInfo.py +8 -0
- pyhw-0.7.3/src/pyhw/backend/gpu/linux.py +46 -0
- 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.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/host/hostBase.py +4 -1
- pyhw-0.7.3/src/pyhw/backend/host/hostInfo.py +13 -0
- pyhw-0.7.3/src/pyhw/backend/host/linux.py +65 -0
- pyhw-0.7.3/src/pyhw/backend/host/macos.py +279 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/kernelBase.py +4 -6
- pyhw-0.7.3/src/pyhw/backend/kernel/kernelInfo.py +10 -0
- pyhw-0.1.3b0/src/pyhw/backend/kernel/linux.py → pyhw-0.7.3/src/pyhw/backend/kernel/unix.py +3 -14
- 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.7.3/src/pyhw/backend/memory/macos.py +56 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/memory/memoryBase.py +6 -0
- pyhw-0.7.3/src/pyhw/backend/memory/memoryInfo.py +10 -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.7.3/src/pyhw/backend/os/macos.py +54 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/os/osBase.py +6 -0
- pyhw-0.7.3/src/pyhw/backend/os/osInfo.py +17 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/shell/shellBase.py +1 -1
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/shell/unix.py +20 -2
- {pyhw-0.1.3b0 → 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.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/linux.py +5 -10
- pyhw-0.7.3/src/pyhw/backend/uptime/macos.py +40 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/uptimeBase.py +6 -0
- pyhw-0.7.3/src/pyhw/backend/uptime/uptimeInfo.py +7 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/color/colorConfig.py +70 -1
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/frontendBase.py +42 -3
- 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/pyhwUtil/sysctlUtil.py +37 -0
- pyhw-0.7.3/src/pyhw.egg-info/PKG-INFO +131 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw.egg-info/SOURCES.txt +42 -5
- pyhw-0.7.3/src/pyhw.egg-info/requires.txt +1 -0
- pyhw-0.1.3b0/MANIFEST.in +0 -1
- pyhw-0.1.3b0/PKG-INFO +0 -45
- pyhw-0.1.3b0/README.md +0 -31
- pyhw-0.1.3b0/src/pyhw/__init__.py +0 -1
- pyhw-0.1.3b0/src/pyhw/__main__.py +0 -37
- pyhw-0.1.3b0/src/pyhw/backend/gpu/linux.py +0 -43
- pyhw-0.1.3b0/src/pyhw/backend/host/linux.py +0 -50
- pyhw-0.1.3b0/src/pyhw/backend/host/macos.py +0 -5
- pyhw-0.1.3b0/src/pyhw/backend/kernel/macos.py +0 -7
- pyhw-0.1.3b0/src/pyhw/backend/memory/linux.py +0 -32
- pyhw-0.1.3b0/src/pyhw/backend/os/linux.py +0 -62
- pyhw-0.1.3b0/src/pyhw/macos.py +0 -146
- pyhw-0.1.3b0/src/pyhw/pyhwUtil/__init__.py +0 -3
- pyhw-0.1.3b0/src/pyhw/pyhwUtil/pyhwUtil.py +0 -70
- pyhw-0.1.3b0/src/pyhw.egg-info/PKG-INFO +0 -45
- {pyhw-0.1.3b0 → pyhw-0.7.3}/LICENSE +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/setup.cfg +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/host/windows.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/kernel/windows.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/title/unix.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/title/windows.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.1.3b0 → pyhw-0.7.3}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.1.3b0 → 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'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
from .frontend import Printer
|
2
|
+
from .backend import Data
|
3
|
+
from .backend.title import TitleDetect
|
4
|
+
from .backend.host import HostDetect
|
5
|
+
from .backend.kernel import KernelDetect
|
6
|
+
from .backend.shell import ShellDetect
|
7
|
+
from .backend.uptime import UptimeDetect
|
8
|
+
from .backend.os import OSDetect
|
9
|
+
from .backend.cpu import CPUDetect
|
10
|
+
from .backend.gpu import GPUDetect
|
11
|
+
from .backend.memory import MemoryDetect
|
12
|
+
from .backend.nic import NICDetect
|
13
|
+
from .backend.npu import NPUDetect
|
14
|
+
from .pyhwUtil import createDataString
|
15
|
+
from .pyhwUtil import getOS, selectOSLogo
|
16
|
+
|
17
|
+
|
18
|
+
def main():
|
19
|
+
current_os = getOS()
|
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}")
|
22
|
+
return
|
23
|
+
data = Data()
|
24
|
+
data.title = TitleDetect(os=current_os).getTitle().title
|
25
|
+
data.Host = HostDetect(os=current_os).getHostInfo().model
|
26
|
+
data.Kernel = KernelDetect(os=current_os).getKernelInfo().kernel
|
27
|
+
data.Shell = ShellDetect(os=current_os).getShellInfo().info
|
28
|
+
data.Uptime = UptimeDetect(os=current_os).getUptime().uptime
|
29
|
+
data.OS = OSDetect(os=current_os).getOSInfo().prettyName
|
30
|
+
data.CPU = CPUDetect(os=current_os).getCPUInfo().cpu
|
31
|
+
gpu_info = GPUDetect(os=current_os).getGPUInfo()
|
32
|
+
if gpu_info.number > 0:
|
33
|
+
data.GPU = gpu_info.gpus
|
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
|
41
|
+
|
42
|
+
Printer(logo_os=selectOSLogo(OSDetect(os=current_os).getOSInfo().id), data=createDataString(data)).cPrint()
|
43
|
+
|
44
|
+
|
45
|
+
if __name__ == "__main__":
|
46
|
+
main()
|
@@ -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,4 +1,6 @@
|
|
1
1
|
from .linux import CPUDetectLinux
|
2
|
+
from .macos import CPUDetectMacOS
|
3
|
+
from .bsd import CPUDetectBSD
|
2
4
|
from ...pyhwException import OSUnsupportedException
|
3
5
|
|
4
6
|
|
@@ -9,5 +11,9 @@ class CPUDetect:
|
|
9
11
|
def getCPUInfo(self):
|
10
12
|
if self.OS == "linux":
|
11
13
|
return CPUDetectLinux().getCPUInfo()
|
14
|
+
elif self.OS == "macos":
|
15
|
+
return CPUDetectMacOS().getCPUInfo()
|
16
|
+
elif self.OS == "freebsd":
|
17
|
+
return CPUDetectBSD().getCPUInfo()
|
12
18
|
else:
|
13
19
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -1,23 +1,18 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
1
|
import re
|
3
2
|
import os
|
4
|
-
|
5
|
-
|
6
|
-
@dataclass
|
7
|
-
class CPUInfoLinux:
|
8
|
-
cpu = ""
|
9
|
-
model = ""
|
10
|
-
cores = ""
|
11
|
-
frequency = ""
|
3
|
+
from .cpuInfo import CPUInfo
|
12
4
|
|
13
5
|
|
14
6
|
class CPUDetectLinux:
|
15
7
|
def __init__(self):
|
16
|
-
self.__cpuInfo =
|
8
|
+
self.__cpuInfo = CPUInfo()
|
17
9
|
|
18
10
|
def getCPUInfo(self):
|
19
11
|
self.__getCPUInfo()
|
20
12
|
self.__modelClean()
|
13
|
+
self.__handleSBC()
|
14
|
+
if self.__cpuInfo.model == "":
|
15
|
+
self.__cpuInfo.model = "Unknown"
|
21
16
|
if self.__cpuInfo.model != "":
|
22
17
|
self.__cpuInfo.cpu = self.__cpuInfo.model
|
23
18
|
if self.__cpuInfo.cores != "":
|
@@ -53,9 +48,32 @@ class CPUDetectLinux:
|
|
53
48
|
else:
|
54
49
|
for line in cpu_info.split("\n"):
|
55
50
|
if line.startswith("cpu MHz") or line.startswith("clock"):
|
56
|
-
self.__cpuInfo.frequency = float(line.split(
|
51
|
+
self.__cpuInfo.frequency = f"{round(float(line.split(':')[1].strip()) / 1000, 2)} Ghz" # Ghz
|
57
52
|
break
|
58
53
|
|
59
54
|
def __modelClean(self):
|
60
55
|
self.__cpuInfo.model = self.__cpuInfo.model.replace("(R)", "")
|
61
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
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
from .cpuInfo import CPUInfo
|
2
|
+
from ...pyhwUtil import sysctlGetString, sysctlGetInt, getArch
|
3
|
+
|
4
|
+
|
5
|
+
class CPUDetectMacOS:
|
6
|
+
def __init__(self):
|
7
|
+
self.__cpuInfo = CPUInfo()
|
8
|
+
self.__arch = getArch()
|
9
|
+
self.__pCore = 0
|
10
|
+
self.__eCore = 0
|
11
|
+
|
12
|
+
def getCPUInfo(self):
|
13
|
+
if self.__arch == "aarch64":
|
14
|
+
self.__getCPUModel()
|
15
|
+
self.__AppleSiliconBaseFrequency()
|
16
|
+
self.__handleAppleSilicon()
|
17
|
+
self.__cpuInfo.cpu = f"{self.__cpuInfo.model} ({self.__pCore}P, {self.__eCore}E) @ {self.__cpuInfo.frequency}"
|
18
|
+
else:
|
19
|
+
self.__getCPUModel()
|
20
|
+
self.__getCPUCores()
|
21
|
+
self.__getCPUFrequency()
|
22
|
+
# need test on Intel Macs.
|
23
|
+
self.__cpuInfo.cpu = f"{self.__cpuInfo.model.replace('CPU', f'({self.__cpuInfo.cores})')}"
|
24
|
+
return self.__cpuInfo
|
25
|
+
|
26
|
+
def __getCPUModel(self):
|
27
|
+
model = sysctlGetString("machdep.cpu.brand_string")
|
28
|
+
model = model.replace("(R)", "")
|
29
|
+
model = model.replace("(TM)", "")
|
30
|
+
self.__cpuInfo.model = model
|
31
|
+
|
32
|
+
def __getCPUCores(self):
|
33
|
+
cores = sysctlGetString("hw.logicalcpu_max")
|
34
|
+
self.__cpuInfo.cores = cores
|
35
|
+
|
36
|
+
def __getCPUFrequency(self):
|
37
|
+
# sysctl doesn't provide the exact CPU frequency on Apple Silicon Macs, there are some indirect methods
|
38
|
+
# to get the CPU frequency, but can not integrate with Python directly.
|
39
|
+
# C-Based helper module will be added later.
|
40
|
+
# See https://github.com/fastfetch-cli/fastfetch/blob/dev/src/detection/cpu/cpu_apple.c for more details.
|
41
|
+
freq = sysctlGetString("hw.cpufrequency")
|
42
|
+
self.__cpuInfo.frequency = freq
|
43
|
+
|
44
|
+
def __handleAppleSilicon(self):
|
45
|
+
nlevels = sysctlGetInt("hw.nperflevels")
|
46
|
+
if nlevels is not None and nlevels == 2: # currently, Apple Silicon chip only has 2 performance levels.
|
47
|
+
pcore = sysctlGetInt("hw.perflevel0.logicalcpu_max") # level 0 is P-core
|
48
|
+
ecore = sysctlGetInt("hw.perflevel1.logicalcpu_max") # level 1 is E-core
|
49
|
+
if pcore is not None and ecore is not None:
|
50
|
+
self.__pCore = pcore
|
51
|
+
self.__eCore = ecore
|
52
|
+
|
53
|
+
def __AppleSiliconBaseFrequency(self):
|
54
|
+
# see https://en.wikipedia.org/wiki/Apple_silicon#M_series for more details.
|
55
|
+
freq = {
|
56
|
+
"Apple M1": "2.30 GHz",
|
57
|
+
"Apple M1 Pro": "2.32 GHz",
|
58
|
+
"Apple M1 Max": "2.32 GHz",
|
59
|
+
"Apple M1 Ultra": "2.32 GHz",
|
60
|
+
"Apple M2": "3.50 GHz",
|
61
|
+
"Apple M2 Pro": "3.50 GHz",
|
62
|
+
"Apple M2 Max": "3.69 GHz",
|
63
|
+
"Apple M2 Ultra": "3.70 Ghz",
|
64
|
+
"Apple M3": "4.05 GHz",
|
65
|
+
"Apple M3 Pro": "4.05 GHz",
|
66
|
+
"Apple M3 Max": "4.05 GHz",
|
67
|
+
"Apple M4": "4.40 GHz",
|
68
|
+
"Apple M4 Pro": "4.40 GHz",
|
69
|
+
"Apple M4 Max": "4.40 GHz"
|
70
|
+
}
|
71
|
+
self.__cpuInfo.frequency = freq.get(self.__cpuInfo.model, "Unknown")
|
@@ -1,4 +1,6 @@
|
|
1
1
|
from .linux import GPUDetectLinux
|
2
|
+
from .macos import GPUDetectMacOS
|
3
|
+
from .bsd import GPUDetectBSD
|
2
4
|
|
3
5
|
|
4
6
|
class GPUDetect:
|
@@ -8,5 +10,9 @@ class GPUDetect:
|
|
8
10
|
def getGPUInfo(self):
|
9
11
|
if self.OS == "linux":
|
10
12
|
return GPUDetectLinux().getGPUInfo()
|
13
|
+
elif self.OS == "macos":
|
14
|
+
return GPUDetectMacOS().getGPUInfo()
|
15
|
+
elif self.OS == "freebsd":
|
16
|
+
return GPUDetectBSD().getGPUInfo()
|
11
17
|
else:
|
12
18
|
raise NotImplementedError("Unsupported operating system")
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import subprocess
|
2
|
+
from .gpuInfo import GPUInfo
|
3
|
+
from ..cpu import CPUDetect
|
4
|
+
from ...pyhwUtil import getArch
|
5
|
+
import pypci
|
6
|
+
|
7
|
+
|
8
|
+
class GPUDetectLinux:
|
9
|
+
def __init__(self):
|
10
|
+
self.__gpuInfo = GPUInfo()
|
11
|
+
|
12
|
+
def getGPUInfo(self):
|
13
|
+
self.__getGPUInfo()
|
14
|
+
self.__sortGPUList()
|
15
|
+
return self.__gpuInfo
|
16
|
+
|
17
|
+
def __getGPUInfo(self):
|
18
|
+
gpu_devices = pypci.PCI().FindAllVGA()
|
19
|
+
if len(gpu_devices) == 0:
|
20
|
+
self.__handleNonePciDevices()
|
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))
|
28
|
+
self.__gpuInfo.number += 1
|
29
|
+
|
30
|
+
def __handleNonePciDevices(self):
|
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.
|
32
|
+
if getArch() == "aarch64" or getArch() == "arm32":
|
33
|
+
self.__gpuInfo.number = 1
|
34
|
+
self.__gpuInfo.gpus.append(f"{CPUDetect(os='linux').getCPUInfo().model} [SOC Integrated]")
|
35
|
+
else:
|
36
|
+
self.__gpuInfo.number = 1
|
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
|
+
|