Python version handling by uv

Every once in a while, an app version gets out of sync with the Python version you’re using locally. For example, viktor.config.toml might specify version 3.11, while you’re developing with 3.13, and Viktor warns you that this might not work. It’s a bit of a pain to switch between Python versions with Viktor. If app A uses 3.11, but later you’re working on app B with version 3.13, you have to change the configuration (viktor-cli configure) and update the Python interpreter path. Then, you have to change it back again when working on app A. While this is doable, it is a little bit frustrating sometimes, and I believe this can be improved.

What if the CLI used uv (which you already use internally) to handle the Python version? viktor.config.toml already has all the information you need. This would ensure that the virtual environment (venv) is always in sync with viktor.config.toml.

Another suggestion would be to let uv sync the venv with the requirements every time you use viktor-cli start, so you can be absolutely sure the venv is in sync with the requirements.

It would be even better if the requirements file could be user-defined, so we could use pyproject.toml for full uv compatibility, but maybe that’s a bridge too far for now.

This is a really good suggestion. I also frequently experience this.

1 Like

Great suggestion!
I also experience this often.

Python is also moving in the same direction as uv and the new changes in PEP 751 would support having the dependencies in pyproject.toml. So, I think the last part of your suggestion is not that far-fetched.

It would be nice if Viktor fully integrates uv. :star_struck:

1 Like

Same here :slight_smile:
Would love to use pyproject.toml in our projects.

1 Like