Python packaging with Hatch, pipx and Zsh environment variables

It’s been a while I didn’t packaged something new. I recently remembered an old package of mine that needed some attention : debts. It’s now time to package it, so I discovered hatch

hatch new —init

This does the heavy-lifting for you, actually porting the files to the new way of packaging with python (with a pyproject.toml file)

Then hatch shell will create a development environment, install dependencies, check the pyproject.toml file in one command, and give you a shell to test whatever you need to test.

Isolating system packages

I discovered that pipx is a convenient way to install user-facing applications on my system. I use multiple virtual environments for my different projects, but not for the install that are used system-wide.

pipx seems to solve this, and avoid using sudo pip install x.

Manipulating env variables with Zsh

I use Zsh as my main shell for years, and I just discovered that it’s possible to manipulate environment variables in an easy way.

If you’re like me, you never remember how to add something to your path. You can actually use +=, like this:

export PATH

#python, #packaging, #zsh - Posté dans la catégorie code