mirror of
https://github.com/almet/notmyidea.git
synced 2025-04-28 19:42:37 +02:00
- More categories are displayed - Change the URL Scheme for categories - Add a view for weeknotes, readings and code.
42 lines
1.4 KiB
Markdown
42 lines
1.4 KiB
Markdown
---
|
|
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](https://gitlab.com/almet/debts). It's now time to package it, so I
|
|
discovered [hatch](https://hatch.pypa.io/)
|
|
|
|
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](https://github.com/pypa/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](https://www.zsh.org/) 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:
|
|
|
|
```zsh
|
|
path+=('/Users/alexis/.local/bin')
|
|
export PATH
|
|
```
|