You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/get-to-know-hatch.md
+49-37Lines changed: 49 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,17 @@
1
-
# Get to know Hatch
1
+
# Get to Know Hatch
2
2
3
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.
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.
10
15
11
16
In this tutorial, you will install and get to know Hatch a bit more before
12
17
starting to use it.
@@ -17,16 +22,14 @@ You need two things to successfully complete this tutorial:
17
22
2. You need Hatch installed.
18
23
19
24
:::{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
+
If you don't already have Python installed on your computer, Hatch will do it
26
+
for you when you install Hatch.
25
27
:::
26
28
27
29
## Install Hatch
28
30
29
-
To begin, follow the operating-specific instructions below to install Hatch.
31
+
To begin, follow the operating-system-specific instructions below to install
32
+
Hatch.
30
33
31
34
::::{tab-set}
32
35
@@ -65,8 +68,8 @@ however, if you prefer another method, check out the [Hatch installation documen
65
68
66
69
### Check that hatch installed correctly
67
70
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:
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:
70
73
71
74
```bash
72
75
hatch --version
@@ -77,38 +80,42 @@ hatch --version
77
80
different from the output above in this tutorial.*
78
81
79
82
:::{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
+
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.
83
86
84
-
Our Linux users have found success installing Hatch with `pipx` if they
85
-
already use `apt install`.
87
+
Our Linux users have found success installing Hatch with pipx if they already
88
+
use apt install.
86
89
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
+
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.
90
93
:::
91
94
92
-
## Configure hatch
95
+
## Configure Hatch
93
96
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.
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.
97
100
98
-
Hatch stores your configuration information in a [`config.toml` file](https://hatch.pypa.io/latest/config/project-templates/).
101
+
Hatch stores your configuration in a [`config.toml` file](https://hatch.pypa.io/latest/config/project-templates/).
99
102
100
-
While you can update the `config.toml` file through the command line,
101
-
it might be easier to look at it and update it in a text editor if you are using it for the first time.
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.
102
106
103
-
### Step 1: Open and edit your`config.toml`file
107
+
### Step 1: Open and Edit Your`config.toml`File
104
108
105
-
To open the config file in your file browser, run the following command in your shell:
109
+
To open the config file in your file browser, run the following command in your
110
+
shell:
106
111
107
112
`hatch config explore`
108
113
109
-
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.
110
116
111
-
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:
112
119
113
120
```bash
114
121
hatch config find
@@ -117,7 +124,9 @@ hatch config find
117
124
118
125
### Step 2 - update your email and name
119
126
120
-
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.
121
130
122
131
```toml
123
132
[template]
@@ -174,7 +183,8 @@ src-layout = true
174
183
175
184
Also notice that the default license option is MIT. While we will discuss
176
185
license in more detail in a later lesson, the MIT license is the
177
-
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
178
188
use it for this tutorial series.
179
189
180
190
You are of course welcome to select another license.
@@ -189,7 +199,9 @@ Once you have completed the steps above run the following command in your shell.
189
199
190
200
`hatch config show`
191
201
192
-
`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
0 commit comments