
Show HN: Hatch – A modern project, package, and virtual env manager for Python - ofek
https://github.com/ofek/hatch
======
Flimm
The README.rst documents the `egg` subcommand like this:

> Creates a new Python project. Think of an "egg" as a new idea.

How does this differ from the egg distribution format [1] introduced by
setuptools, which wheel aims to replace? If it's completely different,
couldn't a distinct term be used? Python packaging is confusing enough as it
is!

[1] - [https://packaging.python.org/glossary/#term-
egg](https://packaging.python.org/glossary/#term-egg)

~~~
PrimHelios
From what I can tell, the egg subcommand doesn't create any kind of egg file,
just creates a new project.

But I agree. Creating a new distinct keyword for that command (why not just
`hatch new my-app`?) would be far better. I've tried to get into Python
packaging, and it's the biggest PITA I've dealt with as a dev.

~~~
pmoriarty
I can recommend this great video from PyCon 2017 which demystifies a lot of
Python's packaging process: [1]

But it's still a mess only Rube Goldberg could love.

[1] - [https://www.youtube.com/watch?v=qOH-h-
EKKac](https://www.youtube.com/watch?v=qOH-h-EKKac)

------
bvrmn
I don't want to be suspicious and negative but here is yet another needless
dependency without any real value. mkvirtualenv is the best tool to manage
venvs, pytest with pytest-cov to test and there is so much benefit to know
original instruments but not some inferior wrapper. If you bothered by bugs in
pip it's better to fix it in pip. All community will be grateful. But another
wrapper is a complete shame.

~~~
mlevental
what are the differences between these things:

pip

easy_install

virtualenv

mkvirtualenv

pipenv

pyenv

~~~
daenney
pip: Python's official package manager

easy_install: Forget it existed, substitute with pip

virtualenv: A virtual environment, providing an isolated Python and libraries

mkvirtualenv: A script to create a virtualenv

pipenv: Combines pip and virtualenv into an integrated solution, comes with a
Pipfile not unlike Ruby's Gemfile for example

pyenv: Script that helps to install and manage different Python versions on
your system, so you can have the full range of Python 2.x and 3.x installed
without them getting in the way of each other. Allows you to set local,
default and system Pythons allowing you to switch your Python interpreter
depending on which project/directory you're in

~~~
mlevental
pyenv also has pyenv-virtualenv...

~~~
cheapsteak
By itself, pyenv is only responsible for isolating python versions (e.g. 2.6,
2.7, 3.3. this would be like rvm/rbenv/nvm).

pyenv-virtualenv is a wrapper to allow pyenv and virtualenv to work together

------
s0l1dsnak3123
I've stopped using any other virtual env managers than asdf[0]- it has one
simple API for pretty much everything.

You can define a .tools-versions file in the root of your project, which lets
you install the correct versions with a simple `asdf install`. We even use
this in CI for zero-config language version upgrades.

[0]: [https://github.com/asdf-vm/asdf](https://github.com/asdf-vm/asdf)

~~~
brudgers
I read "asdf" and wondered, "Using Common Lisp to configure Python?" Then I
followed the link and am curious whether or not it is a port of the widely
used (in) Common Lisp tool.

[https://common-lisp.net/project/asdf/](https://common-lisp.net/project/asdf/)

------
ofek
(Author here) I'm happy to answer any questions!

~~~
CJefferson
What does it do?

I started reading the readme, and after getting past general "this is
awesome", I got to the doc of the config option...

How about showing an example usage, which does something simple and cool?

~~~
levi_n
Agreed, a quick-start example at the top would be both helpful and engaging.

~~~
ofek
Working on that now!

------
captn3m0
Nice to see Python 2 compatibility. I started using poet[0] recently, and
faced issues once I tried adding Python 2 support.

[0]: [https://github.com/sdispater/poet](https://github.com/sdispater/poet)

~~~
levi_n
Unless I'm mistaken, Hatch is only 3.5+, but contains a command line option to
specify if a project is 2 compatible.

~~~
ofek
Yes, the tool itself is 3.5+ but what you are working on matters not!

~~~
geoelectric
Oh, that wasn't clear when I originally looked. I'm glad you clarified that.

------
kenneth_reitz
See also: pipenv :)

[http://docs.pipenv.org/en/latest/](http://docs.pipenv.org/en/latest/)

Very different tools, but they cover the same surface area, in spots.

~~~
ofek
Friendly competition {^.^}

------
techdragon
Well I was in the process of writing my own tool to do this after starting to
hit the limits of what I could do with cookiecutter... so I'm hooked.

I expect I'll be writing quite a few pull requests.

------
paultopia
This looks cool! Two things that leap to mind as things I'd like to know after
glancing over the readme:

\- comparison with pipenv

\- how it handles things like `pip freeze` for, e.g., Heroku

~~~
ofek
Thanks and great question! As Hatch does a bunch of different things, I'll
just speak to the package management.

More or less, hatch manages packages based on environments, whereas pipenv
does so based on projects.

When pip supports Pipfiles, hatch will as well. At that point, project based
package management will be supported too.

~~~
paultopia
Cool, thanks!

------
ofek
Fyi, I just significantly uncluttered the readme

------
amelius
Hmm, I'm not sure if I like the idea of a development tool dictating my folder
structure.

~~~
Walkman
Go does this.

------
bitzl
Looks very interesting! Are there any plans to support conda?

~~~
ofek
Thanks!

Eventually, yes.

------
polotics
How is this better than using a Docker image?

~~~
Karunamon
Developing inside a docker image seems like needless complexity to me,
especially when virtualenv takes care of the python environment isolation
already without another layer of indirection. Virtualenvs are just file copies
and PATH vars with some tooling.

~~~
gtirloni
Agreed. If you're on Windows/OSX, it also adds a VM between your host and your
code and file sharing has terrible performance.

~~~
dguo
File sharing performance has gotten much better on OS X, at least:
[https://blog.docker.com/2017/05/user-guided-caching-in-
docke...](https://blog.docker.com/2017/05/user-guided-caching-in-docker-for-
mac/)

~~~
tekromancr
It's still not /great/. I have had to switch from my mac to a new Win10 laptop
for development because the app server in my docker container would take
around 2 mins to detect a change and reboot the app server, which then would
take a few minutes to reboot. Now it's much closer to realtime. I do hope that
docker get's it sorted out soon, as the tooling on windows isn't as good as
what I am used to on osx.

And by tooling, I mean command line. I am using Cmder with Linux subsystem for
Windows, and it STILL isn't half as good as even the terminal built into osx,
let alone iterm.

------
floatboth
Looks like it does a bit too much. I like pipenv
[https://github.com/kennethreitz/pipenv](https://github.com/kennethreitz/pipenv)

~~~
kenneth_reitz
My thoughts exactly :)

------
deepakkarki
Aside : Can someone explain how HN rises topics to the top? (I'm genuinely
curious)

As of writing this comment, this submission has 4 points in 3 hours, and is on
the top half of the front page. (Not saying the project doesn't shouldn't be -
looks pretty awesome tbh).

Does the reputation of the people upvoting it matter? (still surprising it'd
rise given only 4 points in 3 hours). Does the reputation of the person
submitting it matter?

~~~
daenney
Read the FAQ please:
[https://news.ycombinator.com/newsfaq.html](https://news.ycombinator.com/newsfaq.html).
A quick Google would've gotten you to that answer too.

And don't use random topics to ask questions like these, that's what Ask HN
can be used for:
[https://news.ycombinator.com/ask](https://news.ycombinator.com/ask)

