skip to content
[WH LIAO]

UV Python Project Manager Practice

/ 2 min read

Updated:
Table of Contents

UV is An extremely fast Python package and project manager, written in Rust. This article introduces some of the UV workflows I’ve used in practice.

UV Tool for Docling

  • Tools | uv gives a dedicated interface for interacting with command-line interfaces.
  • docling-project/docling simplifies document processing, parsing diverse formats and providing seamless integrations with the gen AI ecosystem.

Docling providees a command-line tool docling to interact with files. Here is an example of how to install it in a fast and clean way using uv, rather than the traditional pip install docling which will cause problems with existing packages.

Install docling

Simply run:

Terminal window
uv tool install docling

If installed on MacOS Apple Silicon, add the mlx-vlm package for using MLX acceleration.

Terminal window
uv tool install --with mlx-vlm docling

Check installed tools

Terminal window
uv tool list
# output:
docling v2.29.0
- docling
- docling-tools

Then test docling by running offical example:

Terminal window
docling https://arxiv.org/pdf/2206.01062

For MacOS Apple Silicon, using MLX acceleration.

Terminal window
docling --pipeline vlm --vlm-model smoldocling https://arxiv.org/pdf/2206.01062

Dependency Sources Setting

Reffering to Dependency Sources, we can set the dependency sources for UV in pyproject.toml.

The supported sources by UV as follows:

  • Index: A package resolved from a specific package index.
  • Git: A Git repository.
  • URL: A remote wheel or source distribution.
  • Path: A local wheel, source distribution, or project directory.
  • Workspace: A member of the current workspace.

The Index source is convienent for China users, we can set the index source to China mirror, such as Tsinghua University in pyproject.toml. This can greatly improve the download speed of dependencies.

pyproject.toml
[tool.uv.index]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true

Another useful source is the Git source, we can set a specific Git source to the repository of the dependencies. Especially for some repository that is not available on the Index source, like some other’s personal forked repositories or our own repositories on Github.

For example, for the stringlifier package, which has denpencies conflicts with other packages, because of its not maintened by the original author. I forked the original respository and fixed some issuses, now the forked repository can be used as a dependency source in pyproject.toml.

pyproject.toml
dependencies = [
"stringlifier",
]
[tool.uv.sources]
stringlifier = { git = "https://github.com/whliao5am/stringlifier" }