blog.notmyidea.org/content/code/2023-08-17.md
Alexis Métaireau 91159ecc80 New version of the website.
- More categories are displayed
- Change the URL Scheme for categories
- Add a view for weeknotes, readings and code.
2023-09-25 16:50:07 +02:00

1.4 KiB

tags
python, packaging, zsh

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 setup.py 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:

path+=('/Users/alexis/.local/bin')
export PATH