This document provides guidance on using UV with ImSwitch for faster package management and reproducible builds.
Install UV following the official instructions:
# macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"# Clone the repository
git clone https://github.com/openUC2/ImSwitch.git
cd ImSwitch
# Create a virtual environment
uv venv
# Activate the environment
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows
# Install ImSwitch in development mode
uv pip install -e .[PyQt5,dev]ImSwitch includes a uv.lock file for reproducible builds. To use it:
# Install from lock file (ensures exact versions)
uv sync
# Update lock file after changing dependencies
uv lockNote: When contributing code, commit the uv.lock file to ensure all developers use identical dependency versions.
UV provides significant performance improvements over pip:
- Faster installations: 10-100x faster package installation
- Better dependency resolution: More reliable resolution of package conflicts
- Improved caching: Intelligent caching reduces repeated downloads
- Parallel downloads: Multiple packages downloaded simultaneously
- Better error messages: More informative error reporting
UV is designed as a drop-in replacement for pip. Most pip commands work with uv pip:
# Old pip commands
pip install package
pip install -r requirements.txt
pip install -e .
# New UV commands
uv pip install package
uv pip install -r requirements.txt
uv pip install -e .For GitHub Actions and CI systems, UV installation is straightforward:
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
export PATH="$HOME/.local/bin:$PATH"
uv pip install -e .[PyQt5]- UV not found: Ensure UV is in your PATH after installation
- Package conflicts: UV's resolver is more strict than pip - this usually indicates real dependency issues
- Cache issues: Clear UV cache with
uv cache cleanif needed
If you're currently using conda/mamba (Option D from README):
# 1. Deactivate conda environment
conda deactivate
# 2. Create new UV-based environment
cd ~/Documents/ImSwitch
uv venv
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
# 3. Install ImSwitch with UV
uv pip install -e .
Why migrate?
- 10-100x faster package installation
- Better dependency resolution
- No need for conda/mamba overhead
- Native Python ecosystem tooling
- UV Documentation: https://docs.astral.sh/uv/
- ImSwitch Issues: https://github.com/openUC2/ImSwitch/issues