Update Python version constraints and enhance project dependencies

- Updated Python version requirement from ">=3.8,<4.0" to ">=3.9,<3.14" in pyproject.toml and requirements.txt.
- Added additional development dependencies: poetry, ipython, flake8, yapf, and pyinstaller.
- Configured multiple package sources for dependency resolution in pyproject.toml.
- Added formatting configurations for yapf and black to maintain code style consistency.
This commit is contained in:
Zhang LongQi 2025-06-06 10:37:00 +08:00
parent 77743885fe
commit e24444305f
5 changed files with 2380 additions and 46 deletions

124
.gitignore vendored
View File

@ -1,2 +1,122 @@
app.dist/*
app.bin
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
devenv
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
.idea
.vscode
.DS_Store
venus/*
*.deb
*.deb.tar

View File

@ -7,7 +7,57 @@ Please use `python3`
* `pip3 install -r requirements.txt`
* `python3 app.py PORT`
### Xnergy充电器控制演示程序说明
### packaging
```shell
poetry install --no-root --all-groups
```
```shell
poetry run nuitka --standalone --onefile --windows-icon-from-ico="C:\PATH\TO\xnergy_favicon.ico" .\app.py
```
```shell
poetry run pyinstaller --onefile --icon="C:\PATH\TO\xnergy_favicon.ico" .\app.py
```
pyinstaller will be faster than nuitka, but sometimes the executable file generated by pyinstaller may be treated as a virus by some antivirus software.
### English Instructions
The Xnergy Charger Control Demo is a tool designed to control Xnergy chargers via RS485 serial communication. This program allows users to set the interval time and repetition count for charging cycles, making it ideal for testing and demonstration purposes.
**Command Syntax**
```
xnergy-example.exe [-h] [-i INTERVAL] [-r REPEAT] [-q] [-v] port
```
**Positional Arguments**
- **port** (Required): The serial port device (e.g., COM3, /dev/ttyUSB0) connected to the Xnergy RCU.
**Optional Arguments**
- `-h, --help`: Show this help message and exit.
- `-i INTERVAL, --interval INTERVAL`: Time interval (in seconds) between charger on/off cycles. Default is 1800 seconds (30 minutes).
- `-r REPEAT, --repeat REPEAT`: Number of times to repeat the charging cycle. Default is 1.
- `-q, --quiet`: Quiet mode. Suppress all output messages.
- `-v, --version`: Show program version number and exit.
**Usage Examples**
1. Basic usage: `xnergy-example.exe COM3`
Controls the charger via COM3 using default interval and 1 repetition.
2. Custom interval and repeats: `xnergy-example.exe -i 3600 -r 5 COM5`
Controls the charger via COM5 with a 1-hour interval and 5 repetitions.
3. Quiet mode: `xnergy-example.exe -q COM5`
Runs on COM5 without displaying any output.
### Xnergy充电器控制演示程序说明
### 中文说明
@ -42,35 +92,3 @@ xnergy-example.exe [-h] [-i INTERVAL] [-r REPEAT] [-q] [-v] port
3. 安静模式:`xnergy-example.exe -q COM5`
在COM5端口上运行不显示任何输出信息。
### English Instructions
The Xnergy Charger Control Demo is a tool designed to control Xnergy chargers via RS485 serial communication. This program allows users to set the interval time and repetition count for charging cycles, making it ideal for testing and demonstration purposes.
**Command Syntax**
```
xnergy-example.exe [-h] [-i INTERVAL] [-r REPEAT] [-q] [-v] port
```
**Positional Arguments**
- **port** (Required): The serial port device (e.g., COM3, /dev/ttyUSB0) connected to the Xnergy RCU.
**Optional Arguments**
- `-h, --help`: Show this help message and exit.
- `-i INTERVAL, --interval INTERVAL`: Time interval (in seconds) between charger on/off cycles. Default is 1800 seconds (30 minutes).
- `-r REPEAT, --repeat REPEAT`: Number of times to repeat the charging cycle. Default is 1.
- `-q, --quiet`: Quiet mode. Suppress all output messages.
- `-v, --version`: Show program version number and exit.
**Usage Examples**
1. Basic usage: `xnergy-example.exe COM3`
Controls the charger via COM3 using default interval and 1 repetition.
2. Custom interval and repeats: `xnergy-example.exe -i 3600 -r 5 COM5`
Controls the charger via COM5 with a 1-hour interval and 5 repetitions.
3. Quiet mode: `xnergy-example.exe -q COM5`
Runs on COM5 without displaying any output.

2170
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,13 +6,45 @@ authors = ["longqi <longqi90@gmail.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.8,<4.0"
python = ">=3.9,<3.14"
minimalmodbus = "^2.1.1"
[tool.poetry.group.dev.dependencies]
nuitka = "^2.7.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.requires-plugins]
poetry-plugin-export = ">=1.8"
poetry-plugin-shell = ">=1.0.1"
[tool.poetry.group.dev.dependencies]
nuitka = "^2.7.2"
poetry = "^2.1.3"
ipython = "^8.11.0"
flake8 = "^7.2.0"
yapf = "^0.43.0"
pyinstaller = "^6.13.0"
[[tool.poetry.source]]
name = "default"
url = "https://pypi.python.org/simple/"
priority = "primary"
[[tool.poetry.source]]
name = "aliyun"
url = "https://mirrors.aliyun.com/pypi/simple/"
priority = "supplemental"
[[tool.poetry.source]]
name = "tsinghua"
url = "https://pypi.tuna.tsinghua.edu.cn/simple/"
priority = "supplemental"
[tool.yapf]
use_tabs = true
column_limit = 120
continuation_align_style = "valign-right"
[tool.black]
line-length = 120

View File

@ -1,2 +1,4 @@
minimalmodbus==2.1.1 ; python_version >= "3.8" and python_version < "4.0"
pyserial==3.5 ; python_version >= "3.8" and python_version < "4.0"
--index-url https://pypi.python.org/simple
minimalmodbus==2.1.1 ; python_version >= "3.9" and python_version < "3.14"
pyserial==3.5 ; python_version >= "3.9" and python_version < "3.14"