Contain

mise-en-place and uv

Image generated with ChatGPT
slides by Lukas Steinwender

mise-en-place (mise)

  • development environment setup tool
    • tool version manager
    • allows switching between set of environment variables
    • can manage and run tasks
  • installs via mise can be much faster than installing from scratch
  • creates isolated environments for each project and knows which versions, environments, etc. to use

mise does most of the things you should do for you


slides by Lukas Steinwender

Global Setup

curl https://mise.run | sh
~/.local/bin/mise --version                                     #testing
echo "" >> ~/.bashrc                                            #add to .bashrc
echo "#%%activate mise-en-place" >> ~/.bashrc                   #add to .bashrc
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc   #add to .bashrc                         
  • global installs
mise use --global python@latest   #latest version of Python                                 
mise use --global uv@latest       #uv python manager
  • inspect
mise list               #installed tools
mise ls-remote <tool>   #all available versions of tool
slides by Lukas Steinwender

Setting Up a Project

  • follow along in your code-snippets git repo
  • navigate to your project root
  • get utilities
mise use python@<version>
mise use uv@<version>
  • set environment variables
mise set MY_VAR=123
slides by Lukas Steinwender

uv

every projects deserves its own virtual environemnt

  • efficient python project manager
    • environments
    • packages
  • written in rust

uv does most of the things you should do for you


slides by Lukas Steinwender

Workflow

  • init project
uv init <project-name>
uv init <project-name> --bare    #minimal project
uv init <project-name> --lib     #library
  • add packages
uv add <package-name>[>=version] [--dev] [--group] [--optional]
uv add git+<https-link>
  • remove packages
uv remove <package-name>
slides by Lukas Steinwender

Integration with venv

uv pip compile pyproject.toml -o requirements.txt 
python3 -m venv .venv
source .venv
pip3 install -r requirements.txt

Comandline Tools

  • powerful for code that is executed often

use a separate uv project for each commandline tool

uv init --package <package-name>
uv run <command>
slides by Lukas Steinwender

End2End Workflow

#create project
mkdir testproject
cd testproject
#add relevant software
mise use python@3.11
mise use uv@latest
#init project
uv init --package .
#run from commandline
uv run testproject
slides by Lukas Steinwender