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:
uv tool install doclingIf installed on MacOS Apple Silicon, add the mlx-vlm package for using MLX acceleration.
uv tool install --with mlx-vlm doclingCheck installed tools
uv tool list# output:docling v2.29.0- docling- docling-toolsThen test docling by running offical example:
docling https://arxiv.org/pdf/2206.01062For MacOS Apple Silicon, using MLX acceleration.
docling --pipeline vlm --vlm-model smoldocling https://arxiv.org/pdf/2206.01062Dependency 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.
[tool.uv.index]url = "https://pypi.tuna.tsinghua.edu.cn/simple"default = trueAnother 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.
dependencies = [ "stringlifier",]
[tool.uv.sources]stringlifier = { git = "https://github.com/whliao5am/stringlifier" }