7 ms·
Show HN: Hatch – A modern project, package, and virtual env manager for Python
- ofek 9y ago(Author here) I'm happy to answer any questions!
- CJefferson 9y agoWhat 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 9y agoAgreed, a quick-start example at the top would be both helpful and engaging.
- ofek 9y agoWorking on that now!
- ofek 9y agoBasically, 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.
- jack6e 9y agoThis 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?
- ofek 9y agoThanks 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/59cfdd4a929240dd82b2e4e25f9c8f6341fe0f78/hatch/utils.py#L16 https://github.com/ofek/hatch/blob/59cfdd4a929240dd82b2e4e25...
- philipov 9y agoDo you support non-python (especially binary) dependencies? Suppose I have an application that ships binaries but uses python as a scripting language.
- deepakkarki 9y agoAside : 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?
- giancarlostoro 9y agoNot 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.
- dec0dedab0de 9y agoI assume reputation, source, and subject, matter. Though I think they are purposely vague on the details to make it harder for people to game.
- daenney 9y agoRead 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
- polotics 9y agoHow is this better than using a Docker image?
- icebraining 9y agoDocker 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.
- yeukhon 9y agoIt 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.
- icebraining 9y agoDocker 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.
- eeZah7Ux 9y ago> 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.
- 9y ago
- captn3m0 9y agoNice 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 9y agoUnless I'm mistaken, Hatch is only 3.5+, but contains a command line option to specify if a project is 2 compatible.
- ofek 9y agoYes, the tool itself is 3.5+ but what you are working on matters not!
- geoelectric 9y agoOh, that wasn't clear when I originally looked. I'm glad you clarified that.
- levi_n 9y agoThank you for clarifying.
- paultopia 9y agoThis 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 9y agoThanks 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 9y agoCool, thanks!
- amelius 9y agoHmm, I'm not sure if I like the idea of a development tool dictating my folder structure.
- Walkman 9y agoGo does this.
- bitzl 9y agoLooks very interesting! Are there any plans to support conda?
- ofek 9y agoThanks! Eventually, yes.
- bvrmn 9y agoI 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 9y agowhat are the differences between these things: pip easy_install virtualenv mkvirtualenv pipenv pyenv
- cheapsteak 9y agoFound 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-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe https://stackoverflow.com/questions/41573587/what-is-the-dif...
- daenney 9y agopip: 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 9y agopyenv also has pyenv-virtualenv...
- Flimm 9y agoThe 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
- dharness 9y agoI 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'
- PrimHelios 9y agoFrom 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 9y agoI 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
- ofek 9y ago0.4.0 changed the name from `egg` to `new` https://github.com/ofek/hatch/commit/5649b3f6c452b670d919fae1a9d4eebb1fbea5a4 https://github.com/ofek/hatch/commit/5649b3f6c452b670d919fae...
- Flimm 9y agoThanks ofek, seemingly small things like this make a huge difference.
- s0l1dsnak3123 9y agoI'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 9y agoI 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/
- floatboth 9y agoLooks like it does a bit too much. I like pipenv https://github.com/kennethreitz/pipenv https://github.com/kennethreitz/pipenv
- kenneth_reitz 9y agoMy thoughts exactly :)
- kenneth_reitz 9y agoSee 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 9y agoFriendly competition {^.^}
- ofek 9y agoFyi, I just significantly uncluttered the readme
- techdragon 9y agoWell 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.