Using uv for managing the dependencies of this blog
I've recently set up a few new machines from which I'm doing my development work on and I've started to use uv much more for package management with python projects.
This blog is a static site generated with Pelican and I figured the time was right to move the dependency management over.
Previously I'd worked with tools like pipenv and poetry and frankly for this site I never saw enough of an advantage using these package managers over using pip freeze > requirements.txt given this is a personal site. I think uv is sufficiently easy and fully featured enough that it makes sense to make the switch. Also uv is fast, one of the things I disliked about pipenv was that locking and dependency resolution could be excruciatingly slow, so much so that it overwhelmed the benefits of using it on many projects I'd worked on before. This was a pity because a lockfile is very useful in ensuring you can get a repeatable build. Because uv is fast you don't have to make this tradeoff.
To be honest the packaging ecosystem in Python has been an extreme mess for a very long time. pip freeze > requirement.txt was good enough for me to use but also the alternatives used to be so much worse. uv is good enough in my professional work that I now am happy to use it on more personal projects. I really hope I don't come to regret this choice in a few years time if there's yet another churn cycle in Python packaging that happens for whatever reason.
After a long day of dealing with dependency issues today I figured I might as well move the package dependency management for this blog over to uv as well.
The pyproject.toml file is really simple:
[project]
name = "pelicansite"
version = "0.1.0"
description = "Janis Lesinskis' blog"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"pelican[markdown]>=4.11.0",
]
[project.optional-dependencies]
markdown = [
"pelican>=4.11.0",
]
Then building the site is done via
$ uv run pelican
I feel more confident that this will run the build step against the packages in a reliable way compared to what I had before.
It took less time to move it over than it did to write this blog post.