Skip to content

Commit 6a7f72b

Browse files
committed
Fix: update hatch install instructions
1 parent 39730c7 commit 6a7f72b

File tree

1 file changed

+77
-15
lines changed

1 file changed

+77
-15
lines changed

tutorials/get-to-know-hatch.md

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,99 @@
11
# Get to know Hatch
22

3-
Our Python packaging tutorials use the tool Hatch.
4-
In this tutorial, you will install and get to know Hatch a bit more before starting to use it.
3+
Our Python packaging tutorials use the tool
4+
[Hatch](https://hatch.pypa.io/latest/). While there are [many great packaging](/package-structure-code/python-package-build-tools)
5+
tool options out there, we have selected to teach Hatch because
6+
7+
1. It is an end-to-end tool that supports most of the steps required to create a quality Python package. Beginners will have fewer tools to learn if they use Hatch.
8+
1. It supports different build back-ends if you ever need to compile code in other languages.
9+
1. As a community, pyOpenSci has decided that Hatch is a user-friendly tool that supports many different scientific Python use cases.
10+
11+
In this tutorial, you will install and get to know Hatch a bit more before
12+
starting to use it.
13+
14+
You need two things to successfully complete this tutorial:
15+
16+
1. You need Python installed.
17+
2. You need Hatch installed.
18+
19+
:::{important}
20+
If you don't already have Python installed, Hatch will do it for you when you
21+
install Hatch.
22+
23+
Hatch uses [UV](https://astral.sh/blog/uv) to install Python. UV is a super
24+
fast Python package installer and resolver written in Rust.
25+
:::
526

627
## Install Hatch
7-
To begin, install Hatch from the command line using [pipx](https://pipx.pypa.io/stable/)
28+
29+
To begin, follow the operating-specific instructions below to install Hatch.
30+
31+
::::{tab-set}
32+
33+
:::{tab-item} MAC
34+
35+
Follow the instructions [here](https://hatch.pypa.io/latest/install/#installers).
36+
37+
* Download the latest GUI installer for MAC [hatch-universal.pkg](https://github.com/pypa/hatch/releases/latest/download/hatch-universal.pkg).
38+
* Run the installer and follow the setup instructions.
39+
* If your terminal is open, then restart it.
40+
41+
:::
42+
43+
:::{tab-item} Windows
44+
45+
* In your browser, download the correct `.msi` file for your system:
46+
[hatch-x64.msi](https://github.com/pypa/hatch/releases/latest/download/hatch-x64.msi)
47+
* Run your downloaded installer file and follow the on-screen instructions.
48+
49+
:::
50+
51+
:::{tab-item} Linux
52+
53+
We suggest that you install Hatch using pipx on Linux.
54+
however, if you prefer another method, check out the [Hatch installation documentation](https://hatch.pypa.io/latest/install/) for other methods.
855

956
```bash
10-
pipx install hatch
57+
# First install pipx
58+
> apt install pipx
59+
# Then install hatch using pipx
60+
> pipx install hatch
1161
```
1262

13-
:::{tip}
14-
Hatch can also be installed directly using `pip` or `conda`, but we encourage you to use `pipx`.
15-
This is because `pipx` will ensure that your package is available across all of your Python
16-
environments on your computer rather than just in the environment that you install it into.
17-
If you install hatch this way you will have to take care that the environment it is installed into
18-
is activated for the command to work.
1963
:::
64+
::::
65+
66+
### Check that hatch installed correctly
2067

21-
You can check that hatch is working properly by issuing a simple command to get the version
68+
Once you have completed the installation instructions above, you can open your terminal, and make sure that Hatch installed correctly using
69+
the command below:
2270

2371
```bash
2472
hatch --version
2573
# Hatch, version 1.9.4
2674
```
2775

28-
Note the version numbers will likely be different
76+
*Note the version number output of `hatch --version` will likely be
77+
different from the output above in this tutorial.*
78+
79+
:::{tip}
80+
Hatch can also be installed directly using `pip` or `conda`. We
81+
encourage
82+
you to follow the instructions above because we have found that the Hatch installers for Windows and Mac are easiest and most efficient.
83+
84+
Our Linux users have found success installing Hatch with `pipx` if they
85+
already use `apt install`.
86+
87+
Both approaches (using a graphical installer on Windows / MAC and `pipx`) ensure that you have Hatch installed
88+
globally. A global install means that Hatch is available
89+
across all of your Python environments on your computer.
90+
:::
2991

3092
## Configure hatch
3193

32-
Once you have installed Hatch, you will want to customize the configuration.
94+
Once you have installed Hatch, you can customize the configuration which
95+
includes the default name and setup that you want to have for every
96+
package that you create using Hatch. While this step is not required, we suggest it.
3397

3498
Hatch stores your configuration information in a [`config.toml` file](https://hatch.pypa.io/latest/config/project-templates/).
3599

@@ -141,14 +205,12 @@ and maintaining your Python package easier.
141205

142206
A few features that Hatch offers
143207

144-
145208
1. it will convert metadata stored in a `setup.py` or `setup.cfg` file to a pyproject.toml file for you (see [Migrating setup.py to pyproject.toml using Hatch](setup-py-to-pyproject-toml.md
146209
))
147210
2. It will help you by storing configuration information for publishing to PyPI after you've entered it once.
148211

149212
Use `hatch -h` to see all of the available commands.
150213

151-
152214
## What's next
153215

154216
In the next lesson you'll learn how to package and make your code installable using Hatch.

0 commit comments

Comments
 (0)