Show HN: Hatch 1.0.0 – Modern, extensible Python project management
github.com
github.com
Ultimately, I don't really care what I use! But python's woeful package management and distribution is actually a factor in my decision criteria for when and how I use it.
If I control the system end to end? Sure, I don't mind messing with python and building something I deploy. If not, I don't want to deal with it or the headaches that come with the gazillion ways the runtime can be installed/packaged. In this situation I've been defaulting to go even though I'm slightly less productive in it.
I just want a community accepted standard solution that gives me an easy way to offer a pip installable package with its dependencies, or a way to package the runtime easily (cross platform) and move it around with my code so I can forget altogether about what's lurking underneath all that.
Poetry is mainly used for managing an _application_ and its dependencies whereas Hatch is more agnostic to the project type and offers plugin-based functionality for the entire workflow (versioning, tox-like environments, publishing) so you can easily build things other than wheel/sdist, test in a Docker container, etc.
Hatch also strictly adheres to standards and eagerly adopts whatever behavior new PEPs dictate while Poetry has a persistent unwillingness to adopt new standards if they are deemed suboptimal (see comments on PEP 621 [1] and PEP 665 [2])
As such, locking support is temporarily blocked https://ofek.dev/hatch/latest/meta/faq/#libraries-vs-applica...
You can continue using other tools like Poetry at the same time https://ofek.dev/hatch/latest/meta/faq/#interoperability
By the way I very much appreciate the eye for design/UX of Poetry's creator, we also share strong opinions on pipenv :)
[1]: https://discuss.python.org/t/5243/12
[2]: https://github.com/python-poetry/poetry/issues/4710#issuecom...
I'm surprised to hear that view, since when I looked into poetry it seemed more designed for libraries than for (web) applications. I'm thinking specifically about this thread about whether it would be desirable to have a config file option for the --no-root command line flag: https://github.com/python-poetry/poetry/issues/2458
I have to say I do like a lot of the design decisions that have gone into hatch. Regardless, it is great to have more compelling options being worked on, and eventually something will get it "right" enough for the important use cases that it becomes a de facto standard and then hopefully a "blessed" option that everyone can rally around.
When I occasionally encounter a version compatibility issue, I pin the offender in setup.py, done.
If reproducible builds/distributions are important, then I add a Dockerfile.
I will say that I primarily develop applications, not libraries meant for wider consumption. If I do create a library, it's for my own narrow use case. It seems like some of the value in these modern frameworks is reducing complexity over multiple supported versions and platforms.
I'm not saying my workflow is in the mainstream necessarily, but the standard community tooling has been fine for me.
I think the repeatability and simplicity combo of this is my favorite approach. I'm all for standard tooling wherever possible.
Simple and effective in my experience.
How is this falling short? Why such a push for different tooling? Why the continued complaints about Python packaging being substandard? Honest questions because I've been using this for web and cli applications for years without issue.
I also use pipx[2] to install Python based tools onto my system so they have their own virtualenv.
However if the transitive-closure in the dependencies contains an sdist package anywhere in the tree, written in a way that wasn't designed to be imported on all platforms (this is rare, but does happen), then it isn't possible to resolve cross platform.
The prevalence of wheels does alleviate this to some extent. I think it is one of the early design decisions that pip can only install/resolve for the current platform and this will be very difficult to unwind. There are movements slowly in a direction that may one day make it possible to statically resolve python packages and remove dynamic dependency metadata or builds happening during dependency resolution.
- https://mail.python.org/archives/list/pypa-committers@python...
- https://mail.python.org/archives/list/pypa-committers@python...
That can also be a good sign. Lots of people using it, lots of people complaining about it. Assuming these issues are tended to (over time), poetry can only come out better, mainly more stable.
Today we've been "fixing" this by using nox or tox, and avoiding adding everything into a big "dev" environment. But the draw of Poetry/PDM was supposed to be "A single tool". Very excited to see where this goes! I've already enjoyed hatchling, which can be used on it's own with other systems. :) (Except Poetry, which doesn't play well with standards or anyone else).
[1]
$ cat req.txt
requests
git+ssh://git@gitlab.com/foo/bar/amber.git@0.4.0
git+ssh://git@gitlab.com/foo/bar/rebam.git@0.4.0
[2] $ cat buildout.cfg
[buildout]
extends = versions.cfg
extensions = mr.developer
auto-checkout = \*
develop = .
show-picked-versions = true
update-versions-file = versions.cfg
sources-dir = git-sources
parts = py
eggs =
amber
rebam
hammer
[sources]
amber = git git@gitlab.com/foo/bar/amber.git@0.4.0
rebma = git git@gitlab.com/foo/bar/rebma.git@0.4.0
[py]
recipe = zc.recipe.egg
eggs =
${buildout:eggs}
interpreter = py-backend
dependent-scripts = trueI see that tox switched at the beginning of March, which is a realtively high-profile project. I'm curious.
I'm using pipenv and poetry, with a slight preference towards poetry.
I want the automatic virtualenv management from poetry with the lockfile for dependency management and resolution
BUT
with the option to use a vendor dir like PDM without virtualenvs
BUT
with hatch's awesome environment management and matrix functionality for tests/docs etc.
Then, I'd love to work out how I can bundle a python runtime against my package so I can ship a single distributable archive that can be placed anywhere to run predictably. Does anyone have any suggestions for something that solves this last part?
The most annoying anti-feature in poetry is inability to override dependencies. In cargo where there is less need (more consistent use of semver, allow multiple copies of deps) they still allow this but not poetry.
https://github.com/tpapastylianou/self-contained-runnable-py...
It serves my purposes very well (which is creating projects that represent standalone experiments).
Sharing in case someone else here finds it useful.
More recently I've modified this a bit to also generate nice html reports straight from the __main__.py file, independently of the underlying python code, and use this as lab books (where each lab book contains a single analysis and its report). I'll upload this template separately when I find the time.
Any chance of hatch covering all of this?
It's like paying someone else to do the thing
This is pretty reproducible across my own, co-workers, and external collaborators to get the exact version.
However, i feel like if with every small change to your libraries your code breaks there would be something wrong haha.
Also I'm not saying it's a perfect solutions. Only that I had a lot of python apps this was never any issue (an d I had a lot of issues)
If you are building a library though, i totally get the point of using
I also got my then-company to make the switch across a dozen projects or so and multiple teams, but it didn't take much convincing; "Pipenv seems to be unmaintained" did a lot of the convincing for me.