Files
cli/dev/website/_posts/2025-01-15-uv.md

3.5 KiB

title, excerpt, draft, nav_exclude
title excerpt draft nav_exclude
Using uv as an installer Reliably packaging & distributing python CLI tools is hard. Dev uses uv in novel ways to make it easy to install the dev CLI, its dependencies and python 3.12. All in an isolated env. false true

{% if page.date %}

{{ page.date | date: "%B %d, %Y" }}

{% endif %}

Using uv as an installer

{: .no_toc }

It's hard to reliably package and distribute python command line tools to end users. Users frequently encounter challenges: dependency version conflicts, virtual environment management, needing to install python or a specific version of python, etc.

Dev employs uv in a couple of novel ways to streamline the installation process:

  1. Install dev with curl https://dev.chat/install.sh | sh even if python isn't already installed.

  2. Users who have python 3.8+ installed can pip install dev-install && dev-install.

Both methods use uv to globally install the dev command line program, with all of its dependencies in an isolated environment. They ensure that dev will run with python 3.12, and install that version if it is not already available.

These uv install methods are especially helpful for dev, because it has a large set of very specific dependencies. Since not all of dev's dependencies are available on all python versions, it requires python 3.9-3.12.

Most users don't want to worry about these details -- they just want a quick way to install and run dev.

One-liners

Users can install dev with a shell one-liner, without even having python previously installed:

curl -LsSf https://dev.chat/install.sh | sh

This installs uv, then uses it to install python 3.12, install the dev command line tool and update the user's shell path. Under the hood, it is simply a copy of uv's own install script https://astral.sh/uv/install.sh with one line added, to install dev as a tool:

ensure "${_install_dir}/uv" tool install --force --python python3.12 dev-chat@latest

dev-install

The dev-install python package allows quick global installation of dev for users who already have python 3.8+ installed. It simply provides the dev-install command line program, which users just need to run once.

pip install dev-install
dev-install

The pip install dev-install installs only two packages: dev-install and the uv python package. This ensures that uv is available in the user's environment. Everything else is installed in a stand-alone environment created by uv.

When the user runs dev-install, it runs uv to install dev as a tool and update the user's shell path if needed:

uv tool install --force --python python3.12 dev-chat
uv tool update-shell

Benefits

These uv install methods have been popular with users, providing a hassle free way to install dev and quickly get started. Installs are also extremely fast, much faster than pip or pipx installs even when uv is also installing python 3.12!

There are also a number of benefits from the perspective of the tool developer/publisher. Since providing these install methods, far fewer users report dependency problems and version conflicts as compared to users who pip install dev-chat. There is also less pressure to rapidly support the newest python versions, since dev always installs with python 3.12.