Skip to main content

Minimal python setup


Here's how I manage my day-to-day Python workflow recently.

asdf #

I rely on asdf for handling multiple Python versions. I favor asdf over pyenv because of its versatility in managing various runtimes, such as Node.js and Ruby, in addition to Python.

venv #

Each project operates within its own virtual environment:

pip #

I use pip and a requirements.txt file to manage dependencies. I prefer keeping my global package list clean by ensuring that a virtual environment is active before installing any packages (pip config set global.require-virtualenv true). This helps prevent accidentally installing a package globally.

pipx #

For installing global python tools like ruff and poetry, I use pipx. It adds extra flexibility, allowing me to install different versions of tools for different Python versions.

For example, executing

Will result in both poetry15_39 (Poetry 1.5 installed for Python 3.9) and poetry17_310 (Poetry 1.7 installed for Python 3.11) being added to your PATH.

unittest #

For testing I rely on unittest builtin module.

flat layout #

I adopt the flat layout.

├── mymodule
│   └── mymodule
│       ├── __init__.py
│       └── __main__.py