astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
27.65k stars 796 forks source link

Feature request: show install time for each package #7074

Open Afoucaul opened 2 months ago

Afoucaul commented 2 months ago

When you run uv sync or uv pip install -r requirements.txt, a bunch of packages get installed. You get a spinner, then a complete list of the packages installed; example:

$ uv sync
Using Python 3.8.12
Creating virtualenv at: .venv
Resolved 53 packages in 23ms
Prepared 12 packages in 7ms
Installed 14 packages in 53ms
 + anyio==4.4.0
 + certifi==2024.8.30
 + charset-normalizer==3.3.2
 + exceptiongroup==1.2.2
 + h11==0.14.0
 + httpcore==1.0.5
 + httpx==0.27.2
 + idna==3.8
 + requests==2.32.3
 + sniffio==1.3.1
 + typing-extensions==4.5.0
 + urllib3==2.2.2

While the total install time is a good metric to know, I would like to know the install time of each specific package. Even though this doesn't directly correlate with wall time, it would be great to identify the slowest packages to install and thus reducing install and build times.

A concrete example: pandas 1.3.5 takes forever to install. But if my project uses pandas==1.3.5 and anything else, say rich, then my uv sync --no-cache output looks like follows - how can I know it's pandas that made the sync take so long?

$ uv sync --no-cache
Using Python 3.8.12
Creating virtualenv at: .venv
Resolved 11 packages in 1ms
   Built pandas==1.3.5
Prepared 10 packages in 3m 28s
Installed 10 packages in 131ms
 + markdown-it-py==3.0.0
 + mdurl==0.1.2
 + numpy==1.24.4
 + pandas==1.3.5
 + pygments==2.18.0
 + python-dateutil==2.9.0.post0
 + pytz==2024.1
 + rich==13.8.0
 + six==1.16.0
 + typing-extensions==4.12.2

I can identify that it's pandas that takes the longest to install, because it's where the spinner hangs for the longest, but I can't get that retrospectively in the logs. Once I've identified that, I was able to upgrade it to a more recent version, that provides pre-built wheels which makes the install much faster (from 3min30 to 2sec) - so identifying which specific package takes long to install has a huge value.

I'd be happy with some --annotate-with-time flag if that works for you!

zanieb commented 2 months ago

Makes sense, though I'm not sure how straight-forward it would be to add. A --timings flag seems reasonable?

Afoucaul commented 2 months ago

--timings sounds perfect!