Skip to content

Commit 59d1e2f

Browse files
authored
Fix: update hatch install instructions
[Tuesday july 2 merge] Fix: update hatch install instructions
2 parents 61281bb + ff8e190 commit 59d1e2f

File tree

2 files changed

+102
-27
lines changed

2 files changed

+102
-27
lines changed

package-structure-code/code-style-linting-format.md

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Also notice that there are no spaces in the imports listed below.
174174
:::
175175

176176
From the project root, run:
177+
177178
```bash
178179
isort src/examplePy/temporal.py
179180
```

tutorials/get-to-know-hatch.md

+101-27
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,121 @@
1-
# Get to know Hatch
1+
# 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
5+
tools](/package-structure-code/python-package-build-tools) out there, we have
6+
selected Hatch because:
7+
8+
1. It is an end-to-end tool that supports most of the steps required to create
9+
a quality Python package. Beginners will have fewer tools to learn if they
10+
use Hatch.
11+
2. It supports different build back-ends if you ever need to compile code in
12+
other languages.
13+
3. As a community, pyOpenSci has decided that Hatch is a user-friendly tool that
14+
supports many different scientific Python use cases.
15+
16+
In this tutorial, you will install and get to know Hatch a bit more before
17+
starting to use it.
18+
19+
You need two things to successfully complete this tutorial:
20+
21+
1. You need Python installed.
22+
2. You need Hatch installed.
23+
24+
:::{important}
25+
If you don't already have Python installed on your computer, Hatch will do it
26+
for you when you install Hatch.
27+
:::
528

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

959
```bash
10-
pipx install hatch
60+
# First install pipx
61+
> apt install pipx
62+
# Then install hatch using pipx
63+
> pipx install hatch
1164
```
1265

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.
1966
:::
67+
::::
68+
69+
### Check that hatch installed correctly
2070

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

2374
```bash
2475
hatch --version
2576
# Hatch, version 1.9.4
2677
```
2778

28-
Note the version numbers will likely be different
79+
*Note the version number output of `hatch --version` will likely be
80+
different from the output above in this tutorial.*
2981

30-
## Configure hatch
82+
:::{tip}
83+
Hatch can also be installed directly using pip or conda. We encourage you to
84+
follow the instructions above because we have found that the Hatch installers
85+
for Windows and Mac are the easiest and most efficient.
86+
87+
Our Linux users have found success installing Hatch with pipx if they already
88+
use apt install.
89+
90+
Both approaches (using a graphical installer on Windows/Mac and pipx) ensure
91+
that you have Hatch installed globally. A global install means that Hatch is
92+
available across all of your Python environments on your computer.
93+
:::
3194

32-
Once you have installed Hatch, you will want to customize the configuration.
95+
## Configure Hatch
3396

34-
Hatch stores your configuration information in a [`config.toml` file](https://hatch.pypa.io/latest/config/project-templates/).
97+
Once you have installed Hatch, you can customize its configuration. This
98+
includes setting the default name and setup for every package you create. While
99+
this step is not required, we suggest that you do it.
35100

36-
While you can update the `config.toml` file through the command line,
37-
it might be easier to look at it and update it in a text editor if you are using it for the first time.
101+
Hatch stores your configuration in a [`config.toml` file](https://hatch.pypa.io/latest/config/project-templates/).
38102

39-
### Step 1: Open and edit your `config.toml` file
103+
While you can update the `config.toml` file through the command line, it might
104+
be easier to look at and update it in a text editor if you are using it for the
105+
first time.
40106

41-
To open the config file in your file browser, run the following command in your shell:
107+
### Step 1: Open and Edit Your `config.toml` File
108+
109+
To open the config file in your file browser, run the following command in your
110+
shell:
42111

43112
`hatch config explore`
44113

45-
This will open up a directory window that will allow you to double click on the file and open it in your favorite text editor.
114+
This will open up a directory window that allows you to double-click on the file
115+
and open it in your favorite text editor.
46116

47-
You can also retrieve the location of the Hatch config file by running the following command in your shell:
117+
You can also retrieve the location of the Hatch config file by running the
118+
following command in your shell:
48119

49120
```bash
50121
hatch config find
@@ -53,7 +124,9 @@ hatch config find
53124

54125
### Step 2 - update your email and name
55126

56-
Once the file is open, update the [template] table of the `config.toml` file with your name and email. This information will be used in any `pyproject.toml` metadata files that you create using Hatch.
127+
Once the file is open, update the [template] table of the `config.toml` file
128+
with your name and email. This information will be used in any `pyproject.toml`
129+
metadata files that you create using Hatch.
57130

58131
```toml
59132
[template]
@@ -110,7 +183,8 @@ src-layout = true
110183

111184
Also notice that the default license option is MIT. While we will discuss
112185
license in more detail in a later lesson, the MIT license is the
113-
recommended permissive license from [choosealicense.com](https://www.choosealicense.com) and as such we will
186+
recommended permissive license from
187+
[choosealicense.com](https://www.choosealicense.com) and as such we will
114188
use it for this tutorial series.
115189

116190
You are of course welcome to select another license.
@@ -125,7 +199,9 @@ Once you have completed the steps above run the following command in your shell.
125199

126200
`hatch config show`
127201

128-
`hatch config show` will print out the contents of your `config.toml` file in your shell. look at the values and ensure that your name, email is set. Also make sure that `tests=false`.
202+
`hatch config show` will print out the contents of your `config.toml` file in
203+
your shell. look at the values and ensure that your name, email is set. Also
204+
make sure that `tests=false`.
129205

130206
## Hatch features
131207

@@ -141,14 +217,12 @@ and maintaining your Python package easier.
141217

142218
A few features that Hatch offers
143219

144-
145220
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
146221
))
147222
2. It will help you by storing configuration information for publishing to PyPI after you've entered it once.
148223

149224
Use `hatch -h` to see all of the available commands.
150225

151-
152226
## What's next
153227

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

0 commit comments

Comments
 (0)