News for hackers. Stuff that matters.
Re:Show HN: Hatch – A modern project, package, and virtual e... by Flimm on Tuesday September 05, 2017 @09:28AM (#15174847)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by PrimHelios on Tuesday September 05, 2017 @10:23AM (#15175455)
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.

Re:Show HN: Hatch – A modern project, package, and virtual e... by pmoriarty on Tuesday September 05, 2017 @02:29PM (#15177877)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:26PM (#15176684)
0.4.0 changed the name from `egg` to `new` https://github.com/ofek/hatch/commit/5649b3f6c452b670d919fae...
Re:Show HN: Hatch – A modern project, package, and virtual e... by Flimm on Tuesday September 05, 2017 @12:52PM (#15176939)
Thanks ofek, seemingly small things like this make a huge difference.
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:56PM (#15176979)
I truly appreciate the feedback :)
Re:Show HN: Hatch – A modern project, package, and virtual e... by dharness on Tuesday September 05, 2017 @10:22AM (#15175446)
I agree. It is definitely a completely different thing and even though 'egg' is a cool word I wish it was just 'hatch create my-app'
Re:Show HN: Hatch – A modern project, package, and virtual e... by bvrmn on Tuesday September 05, 2017 @09:14AM (#15174758)
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.
Re:Show HN: Hatch – A modern project, package, and virtual e... by FullMtlAlcoholc on Tuesday September 05, 2017 @08:41PM (#15180266)
I don't understand this mindset. There are millions of python developers using this language in for everything from from small shell scripts, web scrapers, to apps and. machine learning models.

Yet there is a monolithic additude towards tooling for languages, so much so that experimentation is actively discouraged. In my experience, there is no better way to level up as a developer than releasing and supporting an actual product that solves what you see as problems. Sure, you can contribute to existing projects, but you're going to learn a lot more if you are the owner. This experience, in and of itself, makes it worth it. I don't understand the existential fear and admonishment since the 'superior' tool will be most widely used. Also, there are many more developers today of all stripes and skill levels, more than enough to support the existing toolset, and others that like to play around and experiment with different projects for fun. This is somewhat how biological evolution works... lots of experiments(mutations), almost all are dead ends, but sometimes, that experiment leads to a wildly successful adaptation.

I only have about 4 years experience, but I've never understood this mindset. I see the value of having a primary toolset for a language, but don't see the value of having onw and only one solution. Can someone please explain to me its value?

Re:Show HN: Hatch – A modern project, package, and virtual e... by joseph on Tuesday September 05, 2017 @10:56AM (#15175813)
I use Python daily and have never heard of mkvirtualenv. I started using pyenv a couple years ago and it worked well enough that I stayed with it. It's really a shame that there is no source of truth for packaging in the Python world.
Re:Show HN: Hatch – A modern project, package, and virtual e... by stuaxo on Tuesday September 05, 2017 @03:46PM (#15178508)
mkvirtualenv is part of virtualenvmanager. I'm sure other ways are good, it's my favourite (along with it's peers rmvirtualenv lsvirtualenv).
Re:Show HN: Hatch – A modern project, package, and virtual e... by geoelectric on Tuesday September 05, 2017 @04:15PM (#15178733)
I think you might mean virtualenvwrapper.
Re:Show HN: Hatch – A modern project, package, and virtual e... by eeZah7Ux on Tuesday September 05, 2017 @12:04PM (#15176513)
Nothing negative in pointing out the constant pattern of reinventing the wheel that has been damaging Python for more than a decade.
Re:Show HN: Hatch – A modern project, package, and virtual e... by gnahckire on Tuesday September 05, 2017 @05:07PM (#15179139)
I agree as well. Conda tackles a few of the issues that OP is trying to solve.

https://conda.io/docs/

Re:Show HN: Hatch – A modern project, package, and virtual e... by mlevental on Tuesday September 05, 2017 @09:44AM (#15175019)
what are the differences between these things:

pip

easy_install

virtualenv

mkvirtualenv

pipenv

pyenv

Re:Show HN: Hatch – A modern project, package, and virtual e... by cheapsteak on Tuesday September 05, 2017 @11:57AM (#15176437)
Found a partial answer here (doesn't go into pip and easy_install, those handle installation, the others handle environment isolation) - https://stackoverflow.com/questions/41573587/what-is-the-dif...
Re:Show HN: Hatch – A modern project, package, and virtual e... by daenney on Tuesday September 05, 2017 @01:25PM (#15177254)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by mlevental on Tuesday September 05, 2017 @02:30PM (#15177888)
pyenv also has pyenv-virtualenv...
Re:Show HN: Hatch – A modern project, package, and virtual e... by cheapsteak on Tuesday September 05, 2017 @02:42PM (#15177989)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by s0l1dsnak3123 on Tuesday September 05, 2017 @09:47AM (#15175058)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by brudgers on Tuesday September 05, 2017 @10:45AM (#15175678)
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/

Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @03:42AM (#15173238)
(Author here) I'm happy to answer any questions!
Re:Show HN: Hatch – A modern project, package, and virtual e... by CJefferson on Tuesday September 05, 2017 @07:01AM (#15174015)
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?

Re:Show HN: Hatch – A modern project, package, and virtual e... by levi_n on Tuesday September 05, 2017 @10:06AM (#15175279)
Agreed, a quick-start example at the top would be both helpful and engaging.
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:34PM (#15176766)
Working on that now!
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:33PM (#15176759)
Basically, it combines the core features of many disparate tools into a handful of commands so users have to type less things.

If I had to say what is truly novel here, it would be the virtual env management and shell support.

Re:Show HN: Hatch – A modern project, package, and virtual e... by jack6e on Tuesday September 05, 2017 @09:49AM (#15175088)
This looks interesting and potentially really helpful! I have been keeping my eyes open for something along these lines. As the author, how do you see this project's relation to Conda? And if you see it working alongside of, rather than in place of, Conda, what support does it have for recognizing and using Conda envs?
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:41PM (#15176843)
Thanks for the kind words!

Hatch can replace Conda as a virtual env manager but doesn't really try to compete with it in regards to binary installs.

Hatch does try to detect when a Conda env is in use and will adjust the shell prompt accordingly. https://github.com/ofek/hatch/blob/59cfdd4a929240dd82b2e4e25...

Re:Show HN: Hatch – A modern project, package, and virtual e... by philipov on Tuesday September 05, 2017 @12:32PM (#15176746)
Do you support non-python (especially binary) dependencies? Suppose I have an application that ships binaries but uses python as a scripting language.
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:35PM (#15176786)
install/uninstall/update just uses pip, so yes!
Re:Show HN: Hatch – A modern project, package, and virtual e... by philipov on Tuesday September 05, 2017 @12:39PM (#15176822)
Could I reconfigure it to use conda instead? Conda can install non-python applications but pip isn't very good at that.
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:52PM (#15176942)
Not at the moment, but what an interesting idea! I'll look into doing that.
Re:Show HN: Hatch – A modern project, package, and virtual e... by captn3m0 on Tuesday September 05, 2017 @07:44AM (#15174224)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by levi_n on Tuesday September 05, 2017 @10:09AM (#15175307)
Unless I'm mistaken, Hatch is only 3.5+, but contains a command line option to specify if a project is 2 compatible.
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:46PM (#15176877)
Yes, the tool itself is 3.5+ but what you are working on matters not!
Re:Show HN: Hatch – A modern project, package, and virtual e... by geoelectric on Tuesday September 05, 2017 @06:04PM (#15179494)
Oh, that wasn't clear when I originally looked. I'm glad you clarified that.
Re:Show HN: Hatch – A modern project, package, and virtual e... by levi_n on Wednesday September 06, 2017 @10:13AM (#15183812)
Thank you for clarifying.
Re:Show HN: Hatch – A modern project, package, and virtual e... by kenneth_reitz on Tuesday September 05, 2017 @01:10PM (#15177114)
See also: pipenv :)

http://docs.pipenv.org/en/latest/

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

Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @05:13PM (#15179168)
Friendly competition {^.^}
Re:Show HN: Hatch – A modern project, package, and virtual e... by techdragon on Tuesday September 05, 2017 @09:06PM (#15180391)
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.

Re:Show HN: Hatch – A modern project, package, and virtual e... by paultopia on Tuesday September 05, 2017 @08:42AM (#15174538)
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

Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:44PM (#15176855)
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.

Re:Show HN: Hatch – A modern project, package, and virtual e... by paultopia on Tuesday September 05, 2017 @02:23PM (#15177814)
Cool, thanks!
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @05:15PM (#15179185)
Fyi, I just significantly uncluttered the readme
Re:Show HN: Hatch – A modern project, package, and virtual e... by amelius on Tuesday September 05, 2017 @08:49AM (#15174585)
Hmm, I'm not sure if I like the idea of a development tool dictating my folder structure.
Re:Show HN: Hatch – A modern project, package, and virtual e... by Walkman on Tuesday September 05, 2017 @12:05PM (#15176516)
Go does this.
Re:Show HN: Hatch – A modern project, package, and virtual e... by bitzl on Tuesday September 05, 2017 @09:06AM (#15174701)
Looks very interesting! Are there any plans to support conda?
Re:Show HN: Hatch – A modern project, package, and virtual e... by ofek on Tuesday September 05, 2017 @12:54PM (#15176959)
Thanks!

Eventually, yes.

Re:Show HN: Hatch – A modern project, package, and virtual e... by polotics on Tuesday September 05, 2017 @07:43AM (#15174221)
How is this better than using a Docker image?
Re:Show HN: Hatch – A modern project, package, and virtual e... by Karunamon on Tuesday September 05, 2017 @09:59AM (#15175197)
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.
Re:Show HN: Hatch – A modern project, package, and virtual e... by tekromancr on Tuesday September 05, 2017 @05:26PM (#15179257)
Maybe if what you are building runs comfortably in one app, on one server, with no important discrepancies between your dev system and production.

The environment I work with has docker containers for

    Web App Server
    Background Task Worker Server
    Database
    Redis Node
    Cassandra Node
Getting all of these to work nicely together on linuxes/macOS/Windows in a repeatable fashion across multiple developers is a major headache. Being able to spin the whole cluster up with `docker-compose up -d` turns the whole mess into merely a minor headache.

Most of the time, I only need to work on functionality that depends on DB and WEB nodes, but if I ever need to debug some issue with the worker tasks, it's much easier to have a whole working system available.

Re:Show HN: Hatch – A modern project, package, and virtual e... by gtirloni on Tuesday September 05, 2017 @11:24AM (#15176111)
Agreed. If you're on Windows/OSX, it also adds a VM between your host and your code and file sharing has terrible performance.
Re:Show HN: Hatch – A modern project, package, and virtual e... by dguo on Tuesday September 05, 2017 @01:23PM (#15177237)
File sharing performance has gotten much better on OS X, at least: https://blog.docker.com/2017/05/user-guided-caching-in-docke...
Re:Show HN: Hatch – A modern project, package, and virtual e... by tekromancr on Tuesday September 05, 2017 @05:31PM (#15179292)
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.

Re:Show HN: Hatch – A modern project, package, and virtual e... by icebraining on Tuesday September 05, 2017 @07:56AM (#15174284)
Docker might replace the need for the virtual environment, but doesn't manage the components of a Python project (building, testing, installing and updating dependencies, etc).

Plus, a virtualenv is a much simpler tool, it's essentially just a way to tell the Python interpreter from which directories to load modules, so it's less likely to give you problems.

Re:Show HN: Hatch – A modern project, package, and virtual e... by yeukhon on Tuesday September 05, 2017 @10:12AM (#15175340)
It doesn't. Imagine you just want to run some utility written in Python (let's use youtube-dl since it is been on front page lately), why do I need to install Docker to run a simple command? For isolation? No thanks. Virtualenv was created to isolate overwrittkng and installing dependencies.

Also, want to emulate multi-sites on single machine deployment? You need virtualenv.

Re:Show HN: Hatch – A modern project, package, and virtual e... by icebraining on Tuesday September 05, 2017 @10:31AM (#15175547)
Docker does solve those problems, even if you and I prefer to use other solutions.

And by the way, you don't actually need virtualenv :) we run multiple webapps on a machine by just installing dependencies in a directory (pip -t) in the git repo, and then adding the appropriate PYTHONPATH in the service's startup config. As long as you don't need multiple versions of the Python interpreter, this works fine.

Re:Show HN: Hatch – A modern project, package, and virtual e... by eeZah7Ux on Tuesday September 05, 2017 @11:52AM (#15176395)
> Docker does solve those problems

...with a very computationally expensive solution, and without improving other aspects like security.

A systemd unit on a "chroot" can do the same and provide isolation.

Re:Show HN: Hatch – A modern project, package, and virtual e... by floatboth on Tuesday September 05, 2017 @12:00PM (#15176459)
Is it really computationally expensive? Containers/jails/zones are essentially chroots "on steroids", isolating things other than the filesystem (networking, hostname, process IDs, users, etc.)
Re:Show HN: Hatch – A modern project, package, and virtual e... by 0xCMP on Tuesday September 05, 2017 @01:40PM (#15177403)
Once built a docker container is not expensive, but the idea with Docker is to create immutable, layered containers and rebuilding every time there is a change. Unlike with nodejs, it's harder to volume mount python packages installed in the docker container and so no one does it.

Change in requirements means rebuilding the container which is a very computationally and IO expensive process. So if you can get away with it virtualenv is better, but putting everything in a container so you can simply ship a container is also useful. It's a compromise.

Re:Show HN: Hatch – A modern project, package, and virtual e... by icebraining on Tuesday September 05, 2017 @02:27PM (#15177859)
Rebuilding the container shouldn't be expensive, that's what layers are for.
Re:Show HN: Hatch – A modern project, package, and virtual e... by 0xCMP on Tuesday September 05, 2017 @03:55PM (#15178580)
A layer with your pip requirements being added and then installed is the most expensive part of building a python container so if you change your requirements you invalidate the cache for that layer (and possibly the other layers above).
Re:Show HN: Hatch – A modern project, package, and virtual e... by floatboth on Tuesday September 05, 2017 @12:04PM (#15176511)
Looks like it does a bit too much. I like pipenv https://github.com/kennethreitz/pipenv
Re:Show HN: Hatch – A modern project, package, and virtual e... by kenneth_reitz on Tuesday September 05, 2017 @01:11PM (#15177120)
My thoughts exactly :)
Re:Show HN: Hatch – A modern project, package, and virtual e... by deepakkarki on Tuesday September 05, 2017 @07:06AM (#15174038)
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?

Re:Show HN: Hatch – A modern project, package, and virtual e... by daenney on Tuesday September 05, 2017 @01:28PM (#15177284)
Read the FAQ please: 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

Re:Show HN: Hatch – A modern project, package, and virtual e... by giancarlostoro on Tuesday September 05, 2017 @07:42AM (#15174206)
Not sure but I feel they've fine tuned it more so that posts like this one don't go by completely unnoticed. I also believe the comments are factored into the ranking as well.
Re:Show HN: Hatch – A modern project, package, and virtual e... by dec0dedab0de on Tuesday September 05, 2017 @10:54AM (#15175796)
I assume reputation, source, and subject, matter. Though I think they are purposely vague on the details to make it harder for people to game.