Automatically sync AWS CodeArtifact configuration from pip to uv.
When you run aws codeartifact login --tool pip, it updates your ~/.config/pip/pip.conf with CodeArtifact credentials. However, if you also use uv (the fast Python package installer), you need to manually configure it separately.
codeartifact-uv solves this by automatically syncing your pip configuration to uv's configuration whenever the pip config changes. It extracts all necessary information (domain, account ID, region, repository) directly from your pip config and fetches a fresh authentication token.
- Automatic Configuration Sync: Watches pip config and updates uv config automatically
- No Manual Configuration: All settings extracted from existing pip config
- Fresh Tokens: Fetches new CodeArtifact tokens on each sync
- Multiple Sync Methods: Choose between file watcher or shell hook
- PyPI Fallback: Automatically falls back to PyPI if package not in CodeArtifact (enabled by default)
- Zero Hardcoded Defaults: Works with any CodeArtifact setup
brew tap easytocloud/tap
brew install codeartifact-uv
# Optional: Install fswatch for watch mode
brew install fswatch# Copy the script to your PATH
cp distribution/bin/sync-pip-to-uv /usr/local/bin/
chmod +x /usr/local/bin/sync-pip-to-uvmacOS:
brew install fswatchLinux:
# Debian/Ubuntu
apt-get install inotify-tools
# RHEL/CentOS
yum install inotify-toolsThe file watcher monitors your pip config in the background and automatically syncs whenever it changes.
Start watcher in background:
sync-pip-to-uv watch > /dev/null 2>&1 &Add to your shell startup (~/.zshrc or ~/.bashrc):
# Start sync-pip-to-uv watcher in background
if command -v sync-pip-to-uv >/dev/null 2>&1; then
sync-pip-to-uv watch > /dev/null 2>&1 &
fiWorkflow:
# Login to CodeArtifact (updates pip config)
aws codeartifact login --tool pip
# uv config is automatically updated by the watcher
uv pip install some-packageIf you prefer not to run a background process, use the shell hook which checks for changes before each prompt.
Add to ~/.zshrc or ~/.bashrc:
eval "$(sync-pip-to-uv setup-hook)"Or manually append:
sync-pip-to-uv setup-hook >> ~/.zshrcManually trigger a sync whenever needed:
# After running aws codeartifact login
aws codeartifact login --tool pip
sync-pip-to-uv syncBy default, sync-pip-to-uv configures uv to try CodeArtifact first and fall back to PyPI if a package is not found. This allows you to:
- Use private packages from CodeArtifact
- Automatically fall back to public packages from PyPI
- Avoid needing to manually switch between indexes
Disable PyPI fallback (CodeArtifact only):
# One-time
SYNC_PIP_TO_UV_PYPI_FALLBACK=false sync-pip-to-uv sync
# Permanently in shell
export SYNC_PIP_TO_UV_PYPI_FALLBACK=falseAdd to watcher startup:
# In ~/.zshrc
if command -v sync-pip-to-uv >/dev/null 2>&1; then
export SYNC_PIP_TO_UV_PYPI_FALLBACK=false
sync-pip-to-uv watch > /dev/null 2>&1 &
fi- Reads pip config: Extracts the
index-urlfrom~/.config/pip/pip.conf - Parses CodeArtifact URL: Extracts domain, account ID, region, and repository name
- Fetches fresh token: Uses AWS CLI to get a new CodeArtifact authentication token
- Writes uv config: Creates/updates
~/.config/uv/uv.tomlwith the configuration and token - Caches state: Remembers the pip config state to avoid unnecessary syncs
# 1. Login to CodeArtifact (updates pip config)
$ aws codeartifact login --tool pip --domain my-domain --repository my-repo
# 2. sync-pip-to-uv detects the change and updates uv config
→ Detected change in /home/user/.config/pip/pip.conf
[2025-11-12 15:30:00] Updated /home/user/.config/uv/uv.toml
Domain: my-domain
Repository: my-repo
Region: us-east-1
# 3. uv now uses CodeArtifact automatically
$ uv pip install my-private-packagesync-pip-to-uv sync # Sync pip config to uv config once (default)
sync-pip-to-uv check # Check if pip config has changed
sync-pip-to-uv watch # Watch pip config for changes and auto-sync
sync-pip-to-uv setup-hook # Print shell hook code for .zshrc/.bashrc
sync-pip-to-uv help # Show help messageCreated by aws codeartifact login --tool pip:
[global]
index-url = https://aws:[email protected]/pypi/repo/simple/Generated by sync-pip-to-uv:
# AWS CodeArtifact index
# Auto-generated by sync-pip-to-uv on 2025-11-12 15:30:00
# Source: /home/user/.config/pip/pip.conf
# Domain: my-domain, Account: 123456789012, Region: us-east-1
[[index]]
name = "my-repo"
url = "https://aws:[email protected]/pypi/repo/simple/"
publish-url = "https://aws:[email protected]/pypi/repo/"
default = true
# PyPI fallback - tries CodeArtifact first, falls back to PyPI
[[index]]
name = "pypi"
url = "https://pypi.org/simple/"Note: PyPI fallback is enabled by default. This means:
uvwill first try to install packages from CodeArtifact- If a package is not found in CodeArtifact, it falls back to PyPI
- To disable this behavior, set
SYNC_PIP_TO_UV_PYPI_FALLBACK=false
Symptoms:
Warning: could not retrieve AWS CodeArtifact token
Solutions:
- Ensure AWS CLI is installed and configured:
aws configure - Verify you have CodeArtifact permissions:
aws codeartifact list-repositories - Check AWS credentials are valid:
aws sts get-caller-identity
macOS:
# Install fswatch
brew install fswatch
# Verify it's installed
which fswatchLinux:
# Install inotify-tools
apt-get install inotify-tools # Debian/Ubuntu
yum install inotify-tools # RHEL/CentOS
# Verify it's installed
which inotifywaitSymptoms:
Not a CodeArtifact URL, skipping
Solution: This is normal if you're not using CodeArtifact. The tool only syncs when it detects a CodeArtifact URL in your pip config.
# Check if pip config has changed
sync-pip-to-uv check
echo $? # 0 = changed, 1 = unchanged
# Force a sync
sync-pip-to-uv sync
# Verify uv config was created
cat ~/.config/uv/uv.toml| Feature | codeartifact-uv | ca-uvx |
|---|---|---|
| Purpose | Config sync tool | Wrapper for uvx/uv |
| Approach | Monitors pip config | Wrapper command |
| Configuration | Automatic from pip | Manual or from uv.toml |
| Token Management | Syncs on pip config change | Fresh token per invocation |
| Use Case | Keep pip and uv in sync | Replace uvx command |
Use codeartifact-uv when:
- You already use
aws codeartifact login --tool pip - You want pip and uv to stay in sync automatically
- You prefer transparent configuration management
Use ca-uvx when:
- You want to use uvx with CodeArtifact
- You prefer wrapping commands
- You need per-invocation token refresh
MIT
Contributions welcome! Please open an issue or submit a pull request.