From bca11aa7b82b39a6a249885df64c5695f257f321 Mon Sep 17 00:00:00 2001
From: Veit Schiele <veit@cusy.io>
Date: Tue, 8 Oct 2024 21:08:31 +0200
Subject: [PATCH] :wrench: Switch to pyproject.toml

* Update README, readthedocs config, .gitignore and github workflow
---
 .github/workflows/docs.yml |  2 +-
 .gitignore                 |  6 +++++
 .readthedocs.yaml          |  7 ++++--
 README.rst                 | 16 +++++++-------
 docs/requirements.txt      |  4 ----
 pyproject.toml             | 45 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 65 insertions(+), 15 deletions(-)
 delete mode 100644 docs/requirements.txt
 create mode 100644 pyproject.toml

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 7b49bf8..92b723c 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -17,6 +17,6 @@ jobs:
         cache: pip
         # Keep in sync with .readthedocs.yaml
         python-version-file: .python-version
-    - run: python -m pip install -r docs/requirements.txt
+    - run: python -m pip install -e ".[docs]"
     - run: python -m sphinx -nb html docs/ docs/_build/html
     - run: python -m sphinx -b linkcheck docs/ docs/_build/html
diff --git a/.gitignore b/.gitignore
index b187795..6768b44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,9 @@ mprun_demo.py
 panel-examples
 deploy-panel.html
 test.png
+
+# venv
+.venv/
+
+# pip install -e .
+cusy_design_system.egg-info/
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
index 50a9f65..73d04c0 100644
--- a/.readthedocs.yaml
+++ b/.readthedocs.yaml
@@ -9,7 +9,7 @@ version: 2
 build:
   os: ubuntu-22.04
   tools:
-    python: "3.11"
+    python: "3.12"
 
 # Build documentation in the docs/ directory with Sphinx
 sphinx:
@@ -23,4 +23,7 @@ formats:
 # Optionally declare the Python requirements required to build your docs
 python:
   install:
-  - requirements: docs/requirements.txt
+    - method: pip
+      path: .
+      extra_requirements:
+        - docs
diff --git a/README.rst b/README.rst
index 12a09b9..938c712 100644
--- a/README.rst
+++ b/README.rst
@@ -42,17 +42,17 @@ Installation
 
    .. code-block:: console
 
-      $ python3 -m venv .
-      $ bin/python -m pip install --upgrade pip
-      $ bin/python -m pip install -r docs/requirements.txt
+      $ python3 -m venv .venv
+      $ . .venv/bin/activate
+      $ python -m pip install -e ".[dev]"
 
    … auf Windows:
 
    .. code-block:: ps1con
 
-      C:> python -m venv .
-      C:> Scripts\python -m pip install --upgrade pip
-      C:> Scripts\python -m pip install -r docs/requirements.txt
+      C:> py -m venv .venv
+      C:> Scripts\activate
+      C:> python -m pip install -e ".[dev]"
 
 #. Erstellen der HTML-Dokumentation:
 
@@ -69,7 +69,7 @@ Installation
 
    .. code-block:: console
 
-      $ sphinx-build -ab html docs/ docs/_build/
+      $ python -m sphinx -b html docs/ docs/_build/html/
 
 #. Erstellen eines PDF:
 
@@ -99,7 +99,7 @@ Installation
 
    .. code-block:: console
 
-    $ source bin/activate
+    $ . .venv/bin/activate
     $ cd docs/
     $ make latexpdf
     …
diff --git a/docs/requirements.txt b/docs/requirements.txt
deleted file mode 100644
index cbcb7fa..0000000
--- a/docs/requirements.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-furo
-nbsphinx
-sphinxcontrib-svg2pdfconverter
-sphinx_design
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..8b4cc93
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,45 @@
+[project]
+name = "cusy-design-system"
+version = "24.1.0"
+authors = [
+  { name="Veit Schiele", email="veit@cusy.io" },
+]
+description = "Richtlinien für Benutzeroberflächen, Code-Beispiele, Designtools und Ressourcen"
+readme = "README.rst"
+requires-python = ">=3.9"
+classifiers = [
+    "Programming Language :: Python :: 3",
+    "License :: OSI Approved :: BSD License",
+    "Operating System :: OS Independent",
+]
+dependencies = []
+
+[project.optional-dependencies]
+docs = [
+    "furo",
+    "nbsphinx",
+    "sphinxcontrib-svg2pdfconverter",
+    "sphinx_design",
+]
+
+dev = [
+    "cusy-design-system[docs]",
+    "pre-commit",
+]
+
+[project.urls]
+"Homepage" = "https://github.com/cusyio/cusy-design-system"
+"Bug Tracker" = "https://github.com/cusyio/cusy-design-system/issues"
+
+[tool.black]
+line-length = 79
+
+[tool.isort]
+atomic=true
+force_grid_wrap=0
+include_trailing_comma=true
+lines_after_imports=2
+lines_between_types=1
+multi_line_output=3
+not_skip="__init__.py"
+use_parentheses=true