|
| 1 | +--- |
| 2 | +type: post |
| 3 | +title: Introducing dense-python |
| 4 | +author: Andrew Wray |
| 5 | +subtitle: A convenient template for new Python projects |
| 6 | +date: 2025-07-06 |
| 7 | +summary: The dense-python repository provides a reusable template for starting Python projects quickly. |
| 8 | +tags: ["python", "template"] |
| 9 | +--- |
| 10 | + |
| 11 | +Dense Analysis has released |
| 12 | +[dense-python](https://github.com/dense-analysis/dense-python), a template |
| 13 | +repository designed to help developers spin up new Python projects with minimal |
| 14 | +setup. The repository collects a set of best practices used across Dense |
| 15 | +Analysis projects and packages them into a starting point you can clone and |
| 16 | +modify. |
| 17 | + |
| 18 | +Available on [GitHub](https://github.com/dense-analysis/dense-python), the |
| 19 | +template comes preconfigured with modern tooling for formatting, linting, static |
| 20 | +type checks, and continuous integration. By cloning the repository and |
| 21 | +customizing it for your work, you can skip much of the boilerplate configuration |
| 22 | +typically required when starting from scratch. |
| 23 | + |
| 24 | +### Distroless Python containers |
| 25 | + |
| 26 | +For containerized deployments, `dense-python` includes a reproducible build |
| 27 | +pipeline that produces distroless images. Distroless containers ship only the |
| 28 | +Python runtime and your project code, resulting in smaller and more secure |
| 29 | +images than traditional distributions. The provided `Dockerfile` demonstrates |
| 30 | +how to compile wheels with the `uv` build tool and copy them into the final |
| 31 | +distroless image. Read more about the advantages in [this article on distroless |
| 32 | +Python images](https://alex-moss.medium.com/creating-an-up-to-date-python-distroless-container-image-e3da728d7a80). |
| 33 | + |
| 34 | +### Testing with Network Isolation By Default |
| 35 | + |
| 36 | +The template configures **pytest** so that tests run with socket access disabled |
| 37 | +by default. This makes it easy to catch accidental network calls in unit tests. |
| 38 | +Strict marker checking is also enabled, ensuring that every custom marker is |
| 39 | +declared in your configuration. You can decorate tests with |
| 40 | +`@pytest.mark.allow_network` to enable network access for them explictly. |
| 41 | +Together, these settings help keep tests fast and deterministic. |
| 42 | + |
| 43 | +### Pyright Type Checking |
| 44 | + |
| 45 | +Static type checking is handled by |
| 46 | +[**Pyright**](https://github.com/microsoft/pyright), the engine behind |
| 47 | +[Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) |
| 48 | +in VSCode and also used by [Cursor](https://cursor.com). It offers quick |
| 49 | +feedback on type annotations without slowing down development. A ready-to-use |
| 50 | +`pyproject.toml` configuration is included so that type errors are caught early. |
| 51 | +As ever Dense Analysis recommends using [the |
| 52 | +DAFT](https://denseanalysis.org/projects/daft/) for programming over proprietary |
| 53 | +editors, but they may also be easily configured. |
| 54 | + |
| 55 | +### Package Builds with uv |
| 56 | + |
| 57 | +Instead of naked `pip`, `dense-python` relies on the lightning-fast |
| 58 | +[uv](https://github.com/astral-sh/uv) tool to create virtual environments and |
| 59 | +build distribution packages. This speeds up the packaging process and ensures |
| 60 | +consistent builds across platforms. |
| 61 | + |
| 62 | +### Open for Contributions! |
| 63 | + |
| 64 | +`dense-python` is FOSS and welcomes contributions. If you find a useful |
| 65 | +improvement or fix, open a pull request or start a discussion on the project |
| 66 | +page. We hope this template saves you time on setup so you can focus on writing |
| 67 | +code. |
0 commit comments