From efe930d116d89ddba19fec4e202c5b1549b720fd Mon Sep 17 00:00:00 2001
From: Simon Bjurek <simbj106@student.liu.se>
Date: Fri, 7 Feb 2025 13:31:52 +0000
Subject: [PATCH] Removed requirement txt files and added optional dependencies
 instead.

---
 .gitlab-ci.yml        |  9 ++++-----
 README.md             | 20 +++++++++++++-------
 pyproject.toml        | 16 ++++++++++++++++
 requirements.txt      |  7 -------
 requirements_doc.txt  |  6 ------
 requirements_test.txt |  6 ------
 6 files changed, 33 insertions(+), 31 deletions(-)
 delete mode 100644 requirements.txt
 delete mode 100644 requirements_doc.txt
 delete mode 100644 requirements_test.txt

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4b33da65..f37ae53d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,8 +9,7 @@ before_script:
   - apt-get install -y libxcb-cursor-dev
   - python -m pip install --upgrade pip
   - python --version
-  - pip install -r requirements.txt
-  - pip install $QT_API
+  - pip install .[$QT_API]
   - git fetch --tags
   # - export CXXFLAGS='--coverage'
   # Install without dependencies to make sure that requirements.txt is up-to-date
@@ -18,7 +17,7 @@ before_script:
   - pip show b_asic
   - export QT_API=$QT_API
   # Install test dependencies
-  - pip install -r requirements_test.txt
+  - pip install .[test]
   - export PYTEST_QT_API=$QT_API
 
 .run-test:
@@ -90,7 +89,7 @@ run-doc-test:
   image: python:3.10
   stage: test
   script:
-    - pip install -r requirements_doc.txt
+    - pip install .[doc]
     - sphinx-build -b html docs_sphinx public
     # Run linting on doc-strings
     - pip install black velin
@@ -110,7 +109,7 @@ pages:
   image: python:3.10
   script:
     - apt-get install --yes optipng
-    - pip install -r requirements_doc.txt
+    - pip install .[doc]
     - sphinx-build -b html docs_sphinx public
   artifacts:
     paths:
diff --git a/README.md b/README.md
index d216f6dc..b2b827ee 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ How to build and debug the library during development.
 The following packages are required in order to build the library:
 
 - [Python](https://python.org/) 3.10+
-- Python dependencies (install with `pip install -r requirements.txt` or they will be installed as part of the
+- Python dependencies (install with `pip install .` or they will be installed as part of the
   installation process):
   - [Graphviz](https://graphviz.org/)
   - [Matplotlib](https://matplotlib.org/)
@@ -24,7 +24,7 @@ The following packages are required in order to build the library:
   - [setuptools_scm](https://github.com/pypa/setuptools_scm/)
   - [NetworkX](https://networkx.org/)
   - [QtAwesome](https://github.com/spyder-ide/qtawesome/)
-- Qt 6, with Python bindings, one of:
+- Qt 6, with Python bindings, one of: (install with `pip install .[$BINDING_NAME]`)
   - pyqt6
   - pyside6
 
@@ -35,7 +35,7 @@ To build a binary distribution, the following additional packages are required:
 
 To run the test suite, the following additional packages are required:
 
-- Python (install with `pip install -r requirements_test.txt`):
+- Python (install with `pip install .[test]`):
   - [pytest](https://pytest.org/)
   - [pytest-qt](https://pytest-qt.readthedocs.io/)
   - [pytest-mpl](https://github.com/matplotlib/pytest-mpl/)
@@ -45,7 +45,7 @@ To run the test suite, the following additional packages are required:
 
 To generate the documentation, the following additional packages are required:
 
-- Python (install with `pip install -r requirements_doc.txt`):
+- Python (install with `pip install .[doc]`):
   - [Sphinx](https://www.sphinx-doc.org/)
   - [Furo](https://pradyunsg.me/furo/)
   - [numpydoc](https://numpydoc.readthedocs.io/)
@@ -104,7 +104,7 @@ In `B-ASIC`:
 ```bash
 python3 -m venv env
 source env/bin/activate
-pip install .
+pip install .[test]
 pytest
 ```
 
@@ -115,7 +115,7 @@ In `B-ASIC` (as admin):
 ```bash
 python3 -m venv env
 .\env\Scripts\activate.bat
-pip install .
+pip install .[test]
 pytest
 ```
 
@@ -155,7 +155,13 @@ How to build and use the library as a user.
 ### Installation
 
 ```bash
-pip install .
+pip install .[pyqt6]
+```
+
+or
+
+```bash
+pip install .[pyside6]
 ```
 
 ### Importing
diff --git a/pyproject.toml b/pyproject.toml
index bffec3c7..4250e3be 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,6 +33,22 @@ dynamic = ["version", "authors"]
 [project.optional-dependencies]
 pyqt6 = ["pyqt6"]
 pyside6 = ["pyside6"]
+test = [
+  "pytest",
+  "pytest-cov",
+  "pytest-qt",
+  "pytest-timeout",
+  "pytest-xvfb",
+  "pytest-xdist",
+]
+doc = [
+  "sphinx",
+  "furo",
+  "numpydoc",
+  "sphinx-gallery",
+  "mplsignal",
+  "sphinx-copybutton",
+]
 
 [tool.setuptools]
 zip-safe = false
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index 5fc3bae5..00000000
--- a/requirements.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-numpy
-qtpy
-graphviz>=0.19
-matplotlib>=3.7
-setuptools_scm[toml]>=6.2
-networkx>=3
-qtawesome
diff --git a/requirements_doc.txt b/requirements_doc.txt
deleted file mode 100644
index 4474f492..00000000
--- a/requirements_doc.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-sphinx
-furo
-numpydoc
-sphinx-gallery
-mplsignal
-sphinx-copybutton
diff --git a/requirements_test.txt b/requirements_test.txt
deleted file mode 100644
index 0227dfd7..00000000
--- a/requirements_test.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-pytest
-pytest-cov
-pytest-qt
-pytest-timeout
-pytest-xvfb
-pytest-xdist
-- 
GitLab