Re:Traps for the Unwary in Python’s Import System
by h3mmy on Wednesday August 17, 2022 @09:26PM
(#32504083)
I've used python on and off since 2009 and every time I dive back in, there's a new standard. I feel like there's several 'proper' ways to do things and I don't really mind there being different flavors of packaging frameworks.
I do find it confusing because there's no real documentation of the various frameworks in one place. It makes it unappealing to invest in writing and maintaining anything in python because I don't know if the process I've used is going to deprecated soon.
Just a side note, I did end up finding and using poetry a couple of weeks ago and stuck to that as I was bouncing around setuptools vs pyproject and then needing to decide whether or not I needed a makefile, etc.
Re:Traps for the Unwary in Python’s Import System
by sseagull on Wednesday August 17, 2022 @05:29PM
(#32501964)
But this directly contradicts the link given above - the "official" python packaging tutorial recommends Hatch, and barely mentions poetry...
Re:Traps for the Unwary in Python’s Import System
by zx14 on Wednesday August 17, 2022 @09:33PM
(#32504131)
"Just use X" is not what I want to hear. Python packaging is a pile of garbage. I don't want to have to use a 3rd party tool! Just fix the damn core tools and make them consistent and intuitive!
Sorry, rant over.
In 2022, If you're building an application and are looking for a simple answer, just use Poetry; it's similar enough to what you'll be familiar with if coming from other languages (e.g. yarn, cargo, ...). For most usecases you can just lean on Poetry's venv management; you don't need to do more than `poetry shell` or `poetry run` to get access to it. Poetry will create, and for the most part manage, your pyproject.toml file for you.
If you want a bit more flexibility Virtualenv is part of python now (`python -m venv`). If you're on MacOS you can get great venv management with pyenv and pyenv-virtualenv. And for sure, things get more complex if you're building a library. But I think Poetry is a solid place to start.