Skip to content

Commit 361af06

Browse files
committed
docs: 📝 Decision post on why to use poetry
Closes #4
1 parent 9da6c6e commit 361af06

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

why-poetry.qmd

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: "Why Poetry"
3+
description: "Our reasons for using Poetry for managing Python package dependencies when building Django and Python projects."
4+
author: "Luke W. Johnston"
5+
date: last-modified
6+
categories:
7+
- package dependencies
8+
- virtual environments
9+
- python
10+
---
11+
12+
## Context and Problem Statement
13+
14+
Managing the packages we depend on (e.g. Django) in Python isn't "simply" installing it on your computer. The issue with installing Python packages on your computer is dependency conflicts that occur, where the "dependency trees" of one package require a different dependency tree than another one. So installing a package that requires a specific version of one package, while another package you already have installed requires another version can cause system problems.
15+
16+
The solution to this problem is by using "virtual environments" in Python. These are environments that are separate from the rest of the system and can install any packages without impacting other environments.
17+
18+
The problem is that there multiple ways of creating these virtual environments and managing package dependencies.
19+
20+
## Decision Drivers
21+
22+
- Package dependency management is a critical task, so we need a tool for it.
23+
- Ensuring we have some way of building our Python projects in a way that is less likely to be a "it works on my computer" issue.
24+
25+
## Considered Options
26+
27+
There are (unfortunately) multiple tools to manage package dependencies in Python, for example, listed [here](https://packaging.python.org/en/latest/tutorials/managing-dependencies/#other-tools-for-application-dependency-management) and [here](https://python.libhunt.com/poetry-alternatives). There are also comparison sites like [this](https://ritza.co/articles/gen-articles/pipenv-vs-virtualenv-vs-poetry-vs-pyenv-vs-pip/), [this](https://www.warp.dev/blog/prose-about-poetry), [this](https://dev.to/adamghill/python-package-manager-comparison-1g98), and [this](https://dev.to/frostming/a-review-pipenv-vs-poetry-vs-pdm-39b4) that go into more detail about many of these tools, as well as some descriptive statistics of the popularities of each [here](https://python.libhunt.com/poetry-alternatives).
28+
29+
We'll only cover:
30+
31+
- [Pipenv](https://pipenv.pypa.io/en/latest/index.html)
32+
- [Poetry](https://python-poetry.org/)
33+
- [Hatch](https://hatch.pypa.io/latest/version/)
34+
- [PDM](https://pdm-project.org/latest/usage/dependency/)
35+
36+
### Pipenv
37+
38+
Was designed to combine the functionality of `pip` and `virtualenv`.
39+
40+
- **Pros**:
41+
- Fairly popular
42+
- Has been around for a while
43+
- Only handles package dependencies (no other features)
44+
- **Cons**:
45+
- The design is a bit older and not as intuitive/clear to use
46+
- The documentation is a bit too verbose/technical
47+
- The package caching doesn't seem to be well designed/robust, so packages could get unnecessarily re-installed
48+
- Only handles package dependency management, which means we need another tool to develop software (like a Python package)
49+
50+
### Poetry
51+
52+
- **Pros**:
53+
- Popular and widely used
54+
- Very well designed website and documentation
55+
- Handles package dependencies with lock files (detailed list of packages and versioning)
56+
- Can set up and help manage a Python project (e.g. Python package)
57+
- Designed from the ground up to consider the needs of package development and dependency resolution
58+
- Allows for external plug-ins for further customization
59+
- Similar dependency management to other languages
60+
- Installable with `pipx`
61+
- **Cons**:
62+
- Installation and resolving package dependency trees (so there are no conflicts) can be a bit slow
63+
- Not completely PEP compliant (not yet support [PEP 621](https://peps.python.org/pep-0621/), but an Issue on it is [here](https://github.com/python-poetry/roadmap/issues/3)), though this isn't a critical problem
64+
65+
### Hatch
66+
67+
- **Pros**:
68+
- Very similar to Poetry
69+
- Is fully PEP-compliant
70+
- Is relatively new, and may be the better option in the future
71+
- Is very opinionated
72+
- Good documentation
73+
- Now maintained under the official PyPA
74+
- **Cons**:
75+
- Is very opinionated
76+
- Is relatively new, so might still be working through things
77+
- Not as widely used compared to the others
78+
79+
### PDM
80+
81+
- **Pros**:
82+
- Fully PEP-compliant
83+
- Decent documentation
84+
- **Cons**:
85+
- Relatively new
86+
- Not as widely used or as popular
87+
- Doesn't have distribution specific installation builds (need to use `curl` to install, which isn't the most secure way of installing)
88+
- Can't install through `pipx`
89+
90+
## Decision Outcome
91+
92+
We decided on Poetry because it has amazing documentation, is well designed, and is very popular and widely used.
93+
94+
### Consequences
95+
96+
- Because it isn't fully PEP compliant, we might encounter some issues
97+
- Doesn't have the "official" support that Hatch has, so we might reconsider the decision to use Poetry at a future date

0 commit comments

Comments
 (0)