-
Notifications
You must be signed in to change notification settings - Fork 72
Add: Tutorial for migrating from setup.py to pyproject.toml using Hatch #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
60588c8
905d5bf
a09daed
50c471a
2ca25b3
09a39a6
826fb58
06e170c
558b636
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,21 @@ In this lesson you will learn: | |
|
||
## What is Hatch? | ||
|
||
See [Get to know Hatch](get-to-know-hatch.md). | ||
Hatch is a Python package manager designed to streamline the process of creating, managing, and distributing Python packages. It provides a convenient CLI (Command-Line Interface) for tasks such as creating new projects, managing dependencies, building distributions, and publishing packages to repositories like PyPI. | ||
|
||
:::{admonition} Get to know Hatch | ||
:class: tip | ||
|
||
See [Get to know Hatch](get-to-know-hatch.md) for more information. | ||
|
||
::: | ||
|
||
## Prerequisites | ||
|
||
Before we begin, ensure that you have Hatch installed on your system. You can install it via pip: | ||
|
||
```bash | ||
pip install hatch | ||
pipx install hatch | ||
``` | ||
|
||
## Sample Directory Tree | ||
|
@@ -88,3 +95,25 @@ Now, let's walk through the steps to use Hatch to create a `pyproject.toml` file | |
3. **Review and Customize**: After running the previous command, Hatch will automatically generate a `pyproject.toml` file based on your existing project configuration. Take some time to review the contents of the generated `pyproject.toml` file. You may want to customize certain settings or dependencies based on your project's requirements (see [pyproject.toml tutorial](pyproject-toml.md) for more information about the `pyproject.toml`). | ||
|
||
4. **Verify**: Verify that the `pyproject.toml` file accurately reflects your project configuration and dependencies. You can manually edit the file if needed, but be cautious and ensure that the syntax is correct. | ||
|
||
### Step 5: Delete setup.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This guide switches from an ordered list to numbered headers. Let's stick to one style. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Thanks for pointing it out. Just fixed it to be consistent |
||
|
||
Since we're migrating to using `pyproject.toml` exclusively, the `setup.py` file becomes unnecessary. You can safely delete it from your project directory. | ||
|
||
```bash | ||
rm setup.py | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we don't need to add bash examples for every step. Especially as some readers won't want to do everything in the terminal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. I removed some of these and left only a couple of hatch specific ones. |
||
|
||
### Step 6: Test Build | ||
|
||
Before proceeding further, it's essential to ensure that your project builds successfully using only the `pyproject.toml` file. Run the following command to build your project: | ||
|
||
```bash | ||
hatch build | ||
``` | ||
|
||
This command will build your project based on the specifications in the `pyproject.toml` file. Make sure to check for any errors or warnings during the build process. | ||
|
||
### Step 7: Test Existing Functionality | ||
|
||
After successfully building your project with `pyproject.toml`, it's crucial to ensure that your project's existing functionality remains intact. Run any pre-existing tests to verify that everything still works as expected. |
Uh oh!
There was an error while loading. Please reload this page.