Skip to content

duanluan/py-uv-config-log-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-uv-config-log-example

English | 简体中文

Use uv to manage dependencies, load YAML configuration via PyYAML, generate rotating logs with logging, and compress archived logs using APScheduler and py7zr.

Quick Start (First Run)

# Create project virtual environment
uv venv

# Sync locked dependencies
uv sync

# Install current project in editable mode (provides app1/common imports)
uv pip install -e .

# Run app module
uv run python -m app1.app1


# --- Activate the virtual environment ---
# Windows
.venv\Scripts\activate.bat
# Linux / MacOS
source .venv/bin/activate

# --- Deactivate the virtual environment ---
# Windows
.venv\Scripts\deactivate.bat
# Linux / MacOS
deactivate

Notes:

  • uv run does not require manually activating .venv.
  • If you run uv sync again later, run uv pip install -e . again.

Daily Run

uv run python -m app1.app1

Optional one-off command (without persisting editable install):

uv run --with-editable . python -m app1.app1

Usage in PyCharm

Set once, then reuse:

  1. Interpreter: select project .venv (uv-created environment).
  2. Mark src as Sources Root in Project view.
  3. Run Configuration:
    • Type: Python
    • Run: Module name
    • Module name: app1.app1
    • Working directory: project root
  4. Save the run configuration (optionally as shared).

If you see ModuleNotFoundError: No module named 'app1' or 'common':

uv pip install -e .

Packaging EXE

Initial build:

  • -F single-file executable, -D single-directory executable
  • -n executable name
  • --add-data include resource files
  • -p append search path to sys.path
pyinstaller -n app1 -D --add-data "src/app1/res;res" -p src src/app1/app1.py

Build with .spec:

  • --noconfirm No need to confirm whether to overwrite the last built file
pyinstaller app1.spec --noconfirm

Run EXE:

app1.exe --config _internal\res\config.yml

About

Use uv to manage dependencies, load YAML configuration via PyYAML, generate rotating logs with logging, and compress archived logs using APScheduler and py7zr. | 使用 uv 管理依赖,使用 PyYAML 读取 YAML 配置,基于 logging 输出并轮转日志,再结合 APScheduler 和 py7zr 对归档日志进行压缩清理。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages