Skip to content

Commit a7b6619

Browse files
authored
Add documentation of pyproject.toml (#30)
1 parent 987b951 commit a7b6619

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
# We create a simple docker file that install the necesseary dependencies for the package
1+
# We choose ubuntu 22.04 as our base docker image
22

33
FROM ubuntu:22.04
44

5-
5+
# We install pip and git from https://packages.ubuntu.com/jammy/apt
66
RUN apt-get update && \
77
apt-get install -y python3-pip git
88

9-
# Use modern setuptools from pip instead of apt
9+
# We upgrade pip and install setuptools
1010
RUN pip3 install pip setuptools --upgrade
1111

12+
# We remove the version of setuptools install via apt, as it is outdated
1213
RUN apt-get purge -y python3-setuptools
1314

1415

15-
# Install mypackage
16+
# We set the working directory to install docker dependencies
1617
WORKDIR /tmp/
18+
19+
# We clone the package repo from github and install it and the binder dependencies
1720
RUN git clone https://github.com/jorgensd/reproducibility && \
18-
pip install ./reproducibility[docs]
21+
pip install ./reproducibility[binder]
1922

23+
# We remove the contents of the temporary directory to minimize the size of the image
2024
RUN rm -rf /tmp
2125

2226
# Create user with a home directory
@@ -25,7 +29,7 @@ ARG NB_UID=1000
2529
ENV USER ${NB_USER}
2630
ENV HOME /home/${NB_USER}
2731

28-
# Copy home directory for usage in binder
32+
# Copy home directory for usage with Binder
2933
WORKDIR ${HOME}
3034
COPY . ${HOME}
3135
USER root

pyproject.toml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
1-
[build-system]
2-
requires = ["setuptools>=62.1.0", "wheel"]
1+
[build-system] # Require setuptool version due to https://github.com/pypa/setuptools/issues/2938
2+
requires = ["setuptools>=61.0.0", "wheel"]
33

4-
[tool.setuptools]
5-
package-dir = {"" = "src"}
64

7-
[tool.setuptools.packages.find]
8-
where = ["src"]
9-
10-
11-
[project]
12-
name = "mypackage"
13-
authors = [
5+
[project] # See https://python-poetry.org/docs/pyproject/ for more keywords
6+
name = "mypackage" # Name of your package
7+
authors = [ # List of authors
148
{name = "Jørgen S. Dokken", email = "dokken@simula.no"}
159
]
16-
version = "0.1.0"
17-
description = "Minimal package for adding two numbers"
18-
readme = "README.md"
19-
requires-python = ">=3.8"
20-
license = {file = "LICENSE"}
10+
version = "0.1.0" # Version number
11+
description = "Minimal package for adding two numbers" # Short description of package
12+
readme = "README.md" # Is used for the description field in your package, see: https://python-poetry.org/docs/pyproject/#readme
13+
requires-python = ">=3.8" # Set requirement for minimal python version
14+
license = {file = "LICENSE"} # Path to license file, see: https://spdx.org/licenses/ for options
2115
dependencies = [
2216
'numpy'
2317
]
2418

2519

2620
[project.optional-dependencies]
2721
test = [
28-
"flake8",
29-
"mypy",
30-
"pytest",
31-
"pytest-cov"
22+
"flake8", # Checks code for consistency, see: https://flake8.pycqa.org/en/latest/user/error-codes.html
23+
"mypy", # Makes sure that typing of input/output is consistent
24+
"pytest", # To run test
25+
"pytest-cov" # To create coverage reports
3226
]
3327

3428
docs = [
35-
"sphinx",
36-
"jupyter-book",
37-
"jupytext"
29+
"jupyter-book", # Required to build documentation
30+
"jupytext", # Required to convert .py to .ipynb files
31+
]
32+
33+
binder = [
34+
"jupyterlab" # Required to interface with Binder when having a Dockerfile in root
3835
]
3936

4037
[tool.mypy]
41-
ignore_missing_imports = true
42-
exclude = [
43-
"docs/",
38+
ignore_missing_imports = true # Does not show errors when importing untyped libraries
39+
exclude = [ # We only want mypy to consider files that are not generated in installing or building documentation
40+
"docs/",
4441
"build/"
4542
]

0 commit comments

Comments
 (0)