Skip to content

Add uv package manager support - #42

Open
Daucloud wants to merge 2 commits into
tuna:masterfrom
Daucloud:feature/uv
Open

Add uv package manager support#42
Daucloud wants to merge 2 commits into
tuna:masterfrom
Daucloud:feature/uv

Conversation

@Daucloud

Copy link
Copy Markdown

Add uv package manager support

Summary

This PR adds support for the uv Python package manager to oh-my-tuna, enabling automatic configuration of TUNA PyPI mirrors for uv users.

What's Added

  • New UV class: Implements the Base interface to support uv package manager
  • Configuration management: Automatically configures uv to use TUNA PyPI mirror (https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/)
  • Cross-platform support: Works with both user-level (~/.config/uv/uv.toml) and system-level (/etc/uv/uv.toml) configurations
  • Global/local mode support: Respects the -g/--global flag for system-wide or user-specific configurations

Key Features

  • Detection: Automatically detects if uv is installed via uv --version
  • Status checking: Verifies if TUNA mirror is already configured
  • Activation: Creates proper TOML configuration with TUNA mirror as default index
  • Deactivation: Cleanly removes configuration files when disabling
  • Directory creation: Automatically creates config directories if they don't exist

Configuration Format

The implementation generates a clean TOML configuration:

[[index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/"
default = true

Testing

  • Works in both global (-g) and local modes
  • Properly handles missing configuration directories
  • Safe file operations with appropriate error handling
  • Integrates seamlessly with existing oh-my-tuna workflow

Usage

# Activate uv mirror (user-level)
python oh-my-tuna.py up

# Activate uv mirror (system-level)  
python oh-my-tuna.py up -g

# Check status
python oh-my-tuna.py status

# Deactivate
python oh-my-tuna.py down

This enhancement brings uv support in line with other package managers already supported by oh-my-tuna, providing a consistent experience for Python developers using this modern package manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant