Skip to content

[Talk Suggestion]: Meet UV - the new way of managing Python projects and packages, taking the Python world by storm #39

@VeckoTheGecko

Description

@VeckoTheGecko

Describe the topic for the talk

Feel free to adapt abstract

I have a challenge for you: get a Python script from 4 years ago and try to run it. Does it work first try? Most likely not - the Python version has changed, the packages that you were using then probably aren't the same as in your current environment (or at least the versions are out of date). Managing projects in Python can be a pain - but all of that disappears with UV. UV is a modern Python package manager that streamlines working in Python. Define your dependencies for a project once, 'lock' the dependencies down - then every time you run the project it will work from a completely reproducible virtual environment with no additional headache. Thanks to PEP723 - you can inline dependencies in a single script, allowing you to simply email a script to a coworker and they can perfectly reproduce the environment and results of your script.

Describe the benefit

UV streamlines so much of Python package management that I think it would be really worth the introduction (especially when most people at IMAU dont really need conda in their workflows, and can be served well just with UV).

Would you be capable/willing to give the talk?
Yes I can, but would prefer someone else to give this talk so that they can provide perspective into their specific workflows.

Additional comments

UV docs: https://docs.astral.sh/uv/
PEP 723: https://peps.python.org/pep-0723/

Old description

Describe the topic for the talk

Ping, you've got mail. Its a Python script from a colleague. You try to run it but of course it doesn't work off the bat. After (a) installing pandas, (b) no, an older version of pandas, (c) installing a bunch of other Python packages, and (d) upgrading to Python 3.12 you finally get a working version of the script. Now, as long as you don't touch that Python environment again, you're good to go!

There's a better way. UV allows you to create scripts that are standalone and have all the script metadata (i.e., which packages and version are required, as well as which versions of Python it works with). Using UV with inlined metadata, you can fearlessly send scripts to your colleagues! Leave all the environment/dependency management to UV by running uv run my_script.py, and make your script reproducible into the future.

Describe the benefit

This greatly improves the reproducibility of scripts, and makes them portable. This would be a great benefit for standalone scripts that are used for data processing that might require very specific versions of a package.

Would you be capable/willing to give the talk?
Yes I can, but I'm also happy for someone else to give this talk (as I think it can already be implemented in some workflows at IMAU).

Additional comments

UV docs: https://docs.astral.sh/uv/guides/scripts/#declaring-script-dependencies
PEP 723 (which standardising things to makes this all possible): https://peps.python.org/pep-0723/

There are likely other tools out there already that are able to interpret the inlined metadata available from PEP 723 - UV is just a popular tool that implements it already.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions