Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge remote-tracking branch 'origin/main' into finsberg/add-pre-comm…
…it-hook
  • Loading branch information
finsberg committed Oct 11, 2022
commit a3883b49f5f5e065f6a09c0c77c26877b7986b2c
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,3 @@ repos:
rev: v0.981
hooks:
- id: mypy

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.4.0
hooks:
- id: pretty-format-toml
45 changes: 45 additions & 0 deletions docs/part1/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,48 @@ We recommend using the source layout. See [this chapter](https://py-pkgs.org/04-


## Pyproject.toml
A [toml](https://toml.io/en/) (Tom's Obivous Minimal Language) file is a plain-text file, consisting of [tables](https://toml.io/en/v1.0.0#table)
which are a selection of key-value pairs.

An example is
```toml
[project]
name = "catch_us"
authors = [
{name = "Per Ulv", email = "per@acme.no"},
{name = "Bippe Stankelbein", email = "bippe@roadrunner.no"}
]
version = "x.y.z"
description = "Meep Meep"
# "readme" the description field in your package,
# see: https://python-poetry.org/docs/pyproject/#readme
readme = "README.md"
requires-python = ">=3.8"
# Path to license file, see: https://spdx.org/licenses/
# for a selection of licenses
license = {file = "LICENSE"}
# Direct dependencies
dependencies = [
'acme',
'numpy'
]
```

### Optional dependencies
The core functionality of a package (its classes and functions) might not depend on many other packages.

However, to be able to test the code, check for consistency and create coverage reports, one might meed additional dependencies.

One can therefore specify a second table in the `pyproject.toml` file, called
[project.optional-depencies].
This is treated as a sub-table of `project`.

For instance, if you want to test your package with [pytest](https://docs.pytest.org/en/7.1.x/), you can add
```toml
[project.optional-dependencies]
test = ["pytest"]
```
Then, when installing the package, you call `pip3 install .[test]` instead of `pip3 install .` to get the additional dependencies.

### Other tables
For options related to coverage reports and code consistency, see the [Coverage](./coverage) and [Linting](./linting.md) section, respectively.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ authors = [
{name = "Jørgen S. Dokken", email = "dokken@simula.no"},
{name = "Henrik N. Finsberg", email = "henriknf@simula.no"}
]
version = "0.1.0"
version = "0.1.0"
description = "Minimal package for adding two numbers"
# "readme" the description field in your package, see: https://python-poetry.org/docs/pyproject/#readme
readme = "README.md"
readme = "README.md"
requires-python = ">=3.8"
# Path to license file, see: https://spdx.org/licenses/ for options
license = {file = "LICENSE"}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.