chore: migrate from requirements.txt to uv with pyproject.toml#1688
chore: migrate from requirements.txt to uv with pyproject.toml#1688laurigates wants to merge 1 commit intohacksider:mainfrom
Conversation
Add pyproject.toml with properly typed dependencies, platform-specific
ONNX Runtime variants, and optional dev dependencies. Add mise.toml for
Python version management and justfile for common development tasks.
The requirements.txt remains for backward compatibility with pip users.
uv is the recommended workflow going forward:
uv sync # install dependencies
just start # run with platform GPU
just start-cpu # run CPU-only
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewer's GuideMigrates the project from requirements.txt-based dependency management to a uv + pyproject.toml setup, adds mise-based Python version management and a justfile task runner, and updates gitignore for new artifacts while keeping requirements.txt for backward compatibility. Sequence diagram for running the application with just and uvsequenceDiagram
actor Developer
participant Shell
participant Just
participant Uv as uv
participant Venv as venv_.venv
participant RunPy as run.py
Developer->>Shell: just start
Shell->>Just: invoke_recipe_start
Just->>Uv: uv run run.py --execution-provider default_provider
Uv->>Venv: create_or_use_venv
Uv->>RunPy: execute_within_venv
RunPy-->>Developer: GUI_running_with_GPU_or_coreml
Developer->>Shell: just start-cpu
Shell->>Just: invoke_recipe_start_cpu
Just->>Uv: uv run run.py
Uv->>Venv: create_or_use_venv
Uv->>RunPy: execute_within_venv
RunPy-->>Developer: GUI_running_CPU_only
Flow diagram for justfile tasks and dependenciesflowchart TD
subgraph Setup_group
Setup[setup]
Install[install]
Models[models]
end
subgraph Run_group
Start[start]
StartCpu[start_cpu]
StartWith[start_with_provider]
end
subgraph Test_group
Test[test]
end
subgraph Maintenance_group
Clean[clean]
end
Setup --> Install
Setup --> Models
Install --> UVSync[uv_sync]
UVSync --> Venv[.venv_created_and_synced]
Models --> ModelsDirCreated[create_models_directory]
ModelsDirCreated --> DownloadModel1[download_inswapper_128_fp16.onnx_if_missing]
ModelsDirCreated --> DownloadModel2[download_gfpgan_1024.onnx_if_missing]
Start --> RunGPU[uv_run_run.py_with_default_execution_provider]
StartCpu --> RunCPU[uv_run_run.py_CPU_only]
StartWith --> RunCustom[uv_run_run.py_with_custom_provider]
Test --> Pytest[uv_run_pytest_tests]
Clean --> RemoveVenv[remove_.venv]
Clean --> RemoveLock[remove_uv.lock]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In the pyproject dependencies,
pillow==12.1.1does not appear to be a currently released version on PyPI; consider aligning this pin with an existing version or whatever was previously used inrequirements.txtto avoid resolution failures. - The
onnxruntime-gpu==1.24.2; sys_platform != 'darwin'and unpinnedtensorflow; sys_platform != 'darwin'markers will also apply to non-GPU environments (e.g., Linux/Windows without CUDA, or macOS Intel); if you expect CPU-only setups there, consider narrowing these markers or providing a CPU-only alternative. - In the
modelsrecipe of the justfile, you may want to makecurlfail loudly and avoid writing partial files by adding-f(and perhaps--retry), so transient network issues don't silently leave corrupted model files in themodelsdirectory.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the pyproject dependencies, `pillow==12.1.1` does not appear to be a currently released version on PyPI; consider aligning this pin with an existing version or whatever was previously used in `requirements.txt` to avoid resolution failures.
- The `onnxruntime-gpu==1.24.2; sys_platform != 'darwin'` and unpinned `tensorflow; sys_platform != 'darwin'` markers will also apply to non-GPU environments (e.g., Linux/Windows without CUDA, or macOS Intel); if you expect CPU-only setups there, consider narrowing these markers or providing a CPU-only alternative.
- In the `models` recipe of the justfile, you may want to make `curl` fail loudly and avoid writing partial files by adding `-f` (and perhaps `--retry`), so transient network issues don't silently leave corrupted model files in the `models` directory.
## Individual Comments
### Comment 1
<location path="justfile" line_range="38" />
<code_context>
+ mkdir -p {{ models_dir }}
+ if [ ! -f "{{ models_dir }}/inswapper_128_fp16.onnx" ]; then
+ echo "Downloading inswapper_128_fp16.onnx..."
+ curl -L -o "{{ models_dir }}/inswapper_128_fp16.onnx" \
+ "https://huggingface.co/hacksider/deep-live-cam/resolve/main/inswapper_128_fp16.onnx"
+ else
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider using `curl -f` so HTTP errors cause the script to fail instead of creating a corrupt/empty model file.
Without `-f`, a 404 or other HTTP error still creates a zero-byte file and the script keeps running (even with `set -euo pipefail`). Using `curl -fL -o ...` makes curl fail on HTTP errors, preventing silently corrupted model files.
Suggested implementation:
```
curl -fL -o "{{ models_dir }}/inswapper_128_fp16.onnx" \
```
```
curl -fL -o "{{ models_dir }}/gfpgan-1024.onnx" \
```
</issue_to_address>
### Comment 2
<location path="pyproject.toml" line_range="17" />
<code_context>
+ "psutil==5.9.8",
+ "tk==0.1.0",
+ "customtkinter==5.2.2",
+ "pillow==12.1.1",
+ "opennsfw2==0.10.2",
+ "protobuf==4.25.1",
</code_context>
<issue_to_address>
**issue (bug_risk):** The pinned Pillow version looks unrealistically high and may not exist on PyPI, which will break installs.
Pinning to `pillow==12.1.1` will almost certainly fail with `No matching distribution found`. Please either pin to a verified existing release or use a compatible version range (for example, `>=x.y,<x+1.0`) to avoid breaking installs.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| mkdir -p {{ models_dir }} | ||
| if [ ! -f "{{ models_dir }}/inswapper_128_fp16.onnx" ]; then | ||
| echo "Downloading inswapper_128_fp16.onnx..." | ||
| curl -L -o "{{ models_dir }}/inswapper_128_fp16.onnx" \ |
There was a problem hiding this comment.
suggestion (bug_risk): Consider using curl -f so HTTP errors cause the script to fail instead of creating a corrupt/empty model file.
Without -f, a 404 or other HTTP error still creates a zero-byte file and the script keeps running (even with set -euo pipefail). Using curl -fL -o ... makes curl fail on HTTP errors, preventing silently corrupted model files.
Suggested implementation:
curl -fL -o "{{ models_dir }}/inswapper_128_fp16.onnx" \
curl -fL -o "{{ models_dir }}/gfpgan-1024.onnx" \
| "psutil==5.9.8", | ||
| "tk==0.1.0", | ||
| "customtkinter==5.2.2", | ||
| "pillow==12.1.1", |
There was a problem hiding this comment.
issue (bug_risk): The pinned Pillow version looks unrealistically high and may not exist on PyPI, which will break installs.
Pinning to pillow==12.1.1 will almost certainly fail with No matching distribution found. Please either pin to a verified existing release or use a compatible version range (for example, >=x.y,<x+1.0) to avoid breaking installs.
Summary
Migrate the project's dependency management from bare
requirements.txttouvwith a modernpyproject.toml.pyproject.toml— all dependencies fromrequirements.txtin PEP 517 format with proper platform markers, build system (hatchling), and dev extras (pytest)mise.toml+.python-version— reproducible Python version management via misejustfile— convenient task runner wrapping common commands (just setup,just start,just start-cpu,just test).gitignore— exclude.venv/,uv.lock,.mise.local.tomlrequirements.txtis preserved untouched for users who prefer pip.Why uv?
uv.lock)onnxruntime-siliconon Apple Silicon vsonnxruntime-gpuelsewhere)uv pip install -r requirements.txtstill worksQuick Start (after this PR)
Test plan
uv synccompletes without errors on macOS ARM (onnxruntime-silicon)uv synccompletes without errors on Linux/Windows (onnxruntime-gpu)just start-cpulaunches the GUIpip install -r requirements.txtstill works (backward compat)🤖 Generated with Claude Code
Summary by Sourcery
Adopt uv-based dependency and environment management with a modern pyproject.toml and supporting tooling for running, testing, and maintaining the project.
Build:
Chores: