Python Rediscovered: uv – The Swiss Army Knife for Tooling
About 3 min reading time
As a developer who works extensively with JavaScript and Java, exploring Python anew has been an exciting journey. Back in university, I had already worked with Python, but at that time, I didn’t give much thought to tooling — it just worked, or so it seemed. Today, I understand that tools for dependency management and virtual environments are fundamental for modern software development.
However, much like in the JavaScript ecosystem, I encountered a vast array of options in Python: pip
, poetry
, virtualenv
, and many more. The sheer variety, combined with tutorials often relying on different tools, can feel overwhelming when starting out.
To find a clear entry point, I reached out to my friend Oliver for advice. His response was concise:
Yes. Only uv. It replaces pip, venv, poetry, twine, setuptools, pdm, hatch, and everything else out there.
This recommendation felt like a practical solution to what could otherwise have been a daunting setup process.
What is uv
?
uv
is a Rust-based tool for Python that brings together the functionality of many popular tools. It manages dependencies (pip
), virtual environments (venv
), build processes (poetry
), and more through a unified interface. For someone familiar with JavaScript workflows, it feels similar to npm
or yarn
—but adapted to Python’s ecosystem.
A Project with Flask
To explore what uv
offers, I decided to build a basic “Hello World” application using Flask. It provided a hands-on way to assess the tool’s capabilities.
Initializing the Project
With uv
, you can initialize a project and create a directory in one step:
uv init my_flask_project
cd my_flask_project
This command sets up the directory my_flask_project
and generates a pyproject.toml
file, which serves as the configuration for your project.
Creating a Virtual Environment
A key part of Python development is isolating project dependencies. With uv
, setting up a virtual environment is straightforward:
uv venv
This creates a virtual environment within the project directory and activates it automatically. You’ll notice your shell prompt changes, indicating the environment is active. To deactivate it, use:
deactivate
Later, you can reactivate the environment with:
source .venv/bin/activate
Using a virtual environment ensures that dependencies for one project do not interfere with others or your global Python setup.
Adding Flask as a Dependency
To include Flask in the project, run:
uv add flask
This command installs Flask, updates the pyproject.toml
file to reflect the dependency, and creates or updates the uv.lock
file. The lock file is particularly valuable because it ensures reproducible builds by pinning specific versions of dependencies.
Writing a “Hello World” Application
In the app.py
file, I added the following code:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
Running the Application
With the virtual environment activated, I started the Flask application:
flask run
The Flask server started at http://127.0.0.1:5000/
, and navigating to this URL displayed the expected “Hello World!” message.
Additional Resources
For those interested in learning more about uv
, Oliver has written insightful articles that provide further context:
uv: I am somewhat sold
Oliver shares his initial impressions ofuv
, including its strengths and why it stands out as a tool.My ideal uv-based Dockerfile
A detailed guide to creating an optimized Dockerfile usinguv
, demonstrating how it can simplify containerized Python environments.Two weeks with uv
After two weeks of usinguv
, Oliver reflects on his experience, highlighting both its benefits and potential limitations.
Conclusion
Working with uv
has made my return to Python development much smoother. It combines essential features like dependency management, virtual environments, and a clear project structure into a single tool. For me, it provides a solid foundation for starting new projects without feeling overwhelmed by the tooling landscape.
If you’re looking to (re)discover Python, uv
might be the Swiss Army knife you need. Oliver’s recommendation was spot on — it truly replaces a lot of tools.