@Cyanisok

Dependency Management Tools

It's easy to get frustrated when dealing with a large bunch of requirements, where dependency management tools can be useful - but keep sober and don't get them mixed up in your head!

Docker


Astral-sh/uv

Standard Workflow

uv init # initialize the project
uv venv # create a virtual environment for the project
uv add torch [dependency] # add dependency (e.g., pandas, numpy, etc.)
uv sync # according to project.toml & uv.lock

Specifically, uv sync will do 3 things:

  • Install missing packages
  • Upgrade or downgrade existing packages to the versions specified in the lock file
  • Remove unnecessary packages from the virtual environment that are not listed in the dependencies
  • Install your own source code packages into the current .venv (in edit mode), such that it becomes a top-level package in your virtual environment - it can be imported using an absolute path to any directory, and CLI scripts run normally.
Blog