There are various tools for creating virtual env and I settled down with poetry.
What’s great with poetry is that I can manage dependencies of development and serving. Dependencies of ‘dev’ can be specified using -G.
poetry add <name> # Packages for serving
poetry add <name> -G dev # Packages for development, e.g., ruff
For installing packages for serving, exclude a group as:
poetry install --no-root --without dev
Poetry creates pyproject.toml to list the packages I added. When install, Poetry adds dependencies of dependencies (like ones that’s necessary to install, say, polars) in poetry.lock.
I can install the exactly same dependencies when on other machines as ‘poetry install’ uses lock file.
I use poetry up plugin for updating all packages, and it works smoothly. I can replicate the update pakcage on a remote machine by removing .venv and then reinstalling packages using the lock.