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: package-structure-code/python-package-build-tools.md
+9-11Lines changed: 9 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# Python Packaging Tools
2
2
3
-
<!-- TODO: add a small discussion on what pinning is?-->
4
-
5
3
## Tools for building your package
6
4
7
5
There are a several different build tools that you can use to [create your Python package's _sdist_ and _wheel_ distributions](python-package-distribution-files-sdist-wheel). Below, we discuss the features,
@@ -12,10 +10,9 @@ extensions.
12
10
13
11
:::{figure-md} package-decision-tree
14
12
15
-
<imgsrc="../images/python-package-tools-decision-tree.png"alt="Decision tree diagram showing the various front and back end packaging tools. You can decide what packaging tool to use by thinking about what features you need. PDM is currently the most flexible tool that also supports both non pure Python projects and also using different build back-ends. As such currently PDM is the tool we think beginners might appreciate most with Poetry being a close second. Poetry is ideal for pure python projects."width="700px">
13
+
<imgsrc="../images/python-package-tools-decision-tree.png"alt="Decision tree diagram showing the various front and back end packaging tools. You can decide what packaging tool to use by thinking about what features you need. PDM and Hatch are currently the most flexible tools as they also using different build back-ends. As such currently PDM and Hatch are the tools we think beginners might appreciate most with Poetry being a close second. Poetry is nice for pure Python projects."width="700px">
16
14
17
-
Diagram showing the various from end build tools that you can select from. Each tool has different features as highlighted below.
18
-
NOTE: this is still a DRAFT so i'm not going to spend time truly cleaning it up until i get lots of feedback on the general approach!!
15
+
Diagram showing the different front end build tools available to use in the Python package ecosystem that you can select from. We selected tools to include in this diagram based upon the PyPI survey which helped us understand the most populate tools in the ecosystem. Each tool has different features as highlighted below.
19
16
:::
20
17
21
18
If you want to know more about Python packages that have extensions written in
@@ -207,6 +204,7 @@ front-end tools remove the need to use other core tools in your workflow. For ex
207
204
Note that because setuptools does not offer a front-end interface, it is not
Version Control based versioning (using `git tags`)|✖|✅|✅|✅
@@ -310,7 +308,7 @@ Install your package in editable mode|✅| Flit supports installing your package
310
308
Build your sdist and wheel distributions|✅| Flit can be used to build your packages sdist and wheel distributions.
311
309
```
312
310
313
-
\*\*NOTE: _If you are using the most current version of pip, it supports both a symlink approach `flit install -s` and `pip install -e .`_
311
+
NOTE: _If you are using the most current version of pip, it supports both a symlink approach `flit install -s` and `pip install -e .`_
314
312
315
313
```{admonition} Learn more about flit
316
314
* [Why use flit?](https://flit.pypa.io/en/stable/rationale.html)
@@ -329,6 +327,7 @@ You may NOT want to use flit if:
329
327
- You have a project that is not pure Python (Use Hatch, PDM or setuptools)
330
328
- You want environment management (use PDM, Hatch or Poetry)
331
329
330
+
(hatch)=
332
331
## Hatch
333
332
334
333
[**Hatch**](https://hatch.pypa.io/latest/), similar to Poetry and PDM, provides a
@@ -345,30 +344,29 @@ as building your documentation locally. This means that you could potentially dr
345
344
:widths: 20,5,50
346
345
:delim: "|"
347
346
348
-
Use Other Build Backends|✖| Switching out build back-ends is not currently an option with Hatch. However, this feature is planned for a future release.
347
+
Use Other Build Backends|✅ | Switching out build back-ends is not currently an option with Hatch. However, this feature is planned for a future release.
349
348
Dependency management|✖| Currently you have to add dependencies manually with Hatch. However a feature to support dependencies management may be added in a future release.
350
349
Environment Management |✅ | Hatch supports Python virtual environments. If you wish to use other types of environments such as Conda, you will need to [install a plugin such as hatch-conda for conda support](https://github.com/OldGrumpyViking/hatch-conda).
351
350
Publish to PyPI and test PyPI|✅|Hatch supports publishing to both test PyPI and PyPI
352
351
Version Control based versioning|✅ | Hatch offers `hatch_vcs` which is a plugin that uses setuptools_scm to support versioning using git tags. The workflow with `hatch_vcs` is the same as that with `setuptools_scm`.
353
352
Version bumping| ✅ | Hatch supports you bumping the version of your package using standard semantic version terms patch; minor; major
354
353
Follows current packaging standards|✅|Hatch supports current packaging standards for adding metadata to the **pyproject.toml** file.
355
-
Install your package in editable mode|✖✅| You can install your package in editable mode using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
354
+
Install your package in editable mode|✅| Hatch will install your package into any of its environments by default in editable mode. You can install your package in editable mode manually using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
356
355
Build your sdist and wheel distributions|✅| Hatch will build the sdist and wheel distributions
357
356
✨Matrix environment creation to support testing across Python versions✨|✅| The matrix environment creation is a feature that is unique to Hatch in the packaging ecosystem. This feature is useful if you wish to test your package locally across Python versions (instead of using a tool such as tox).
358
357
✨[Nox / MAKEFILE like functionality](https://hatch.pypa.io/latest/environment/#selection)✨| ✅| This feature is also unique to Hatch. This functionality allows you to create workflows in the **pyproject.toml** configuration to do things like serve docs locally and clean your package build directory. This means you may have one less tool in your build workflow.
359
358
✨A flexible build back-end: **hatchling**✨| ✅| **The hatchling build back-end offered by the maintainer of Hatch allows developers to easily build plugins to support custom build steps when packaging.
360
359
361
360
```
362
361
363
-
_\*\* There is some argument about this approach placing a burden on maintainers to create a custom build system. But others appreciate the flexibility. The Hatch build hook approach is also comparable with the features offered by PDM._
362
+
_There is some argument about this approach placing a burden on maintainers to create a custom build system. But others appreciate the flexibility. The Hatch build hook approach is also comparable with the features offered by PDM._
364
363
365
364
### Why you might not want to use Hatch
366
365
367
366
There are a few features that hatch is missing that may be important for some.
368
367
These include:
369
368
370
369
- Hatch doesn't support adding dependencies. You will have to add them manually.
371
-
- Hatch currently doesn't support use with other build back-ends. Lack of support for other build back-ends makes Hatch less desirable for users with more complex package builds. If your package is pure Python, then this won't be an issue.
372
370
- Hatch won't by default recognize Conda environments without a plugin.
373
371
- Similar to PDM, Hatch's documentation can difficult to work through, particularly if you are just getting started with creating a package.
374
372
- Hatch, similar to PDM and Flit currently only has one maintainer.
0 commit comments