Skip to content

Refine project structure and poetry setup

Use a project structure and poetry setup that is recommended for Python projects:

.
├── data
│   ├── astronaut_data.json
│   └── astronaut_data.json.license
├── LICENSE.md
├── LICENSES
│   ├── CC0-1.0.txt
│   ├── CC-BY-4.0.txt
│   └── MIT.txt
├── poetry.lock
├── poetry.lock.license
├── pyproject.toml
├── README.md
├── results
│   ├── age_box_plot.png
│   ├── age_box_plot.png.license
│   ├── age_histogram.png
│   ├── age_histogram.png.license
│   ├── females_in_space.png
│   ├── females_in_space.png.license
│   ├── humans_in_space.png
│   ├── humans_in_space.png.license
│   ├── males_in_space.png
│   └── males_in_space.png.license
├── src
│   └── astronaut_analysis
│       ├── __init__.py
│       └── __main__.py
└── tests
    ├── astronaut_analysis_test.py
    └── __init__.py

File pyproject.toml then looks like this:

[tool.poetry]
name = "astronaut-analysis"
version = "0.1.0"
description = "Example Python project to illustrate GitLab CI in a workshop."
authors = ["Christian Hueser <c.hueser@hzdr.de>",
           "Norman Ziegner <norman.ziegner@ufz.de>",
           "Tobias Huste <t.huste@hzdr.de>"]
license = "MIT"
packages = [{include = "astronaut_analysis", from = "src"}]

[tool.poetry.scripts]
astronaut-analysis = "src.astronaut_analysis.__main__:perform_analysis"

[tool.pytest.ini_options]
pythonpath = [
  "src"
]

[tool.poetry.dependencies]
python = "^3.10"
pandas = "^1.5.3"
matplotlib = "^3.7.1"

[tool.poetry.dev-dependencies]
black = "^23.1.0"
isort = "^5.12.0"
reuse = "^1.1.2"
pytest = "^7.2.2"
pytest-mpl = "^0.16.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Edited by Hueser, Christian