From 113df982c438278534b52ff7010fb793f19d97d2 Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Wed, 12 Mar 2025 11:55:12 +0100
Subject: [PATCH] Modernise build system

---
 {{cookiecutter.project_slug}}/.gitlab-ci.yml | 24 ++------
 {{cookiecutter.project_slug}}/pyproject.toml | 58 ++++++++++++++++++++
 {{cookiecutter.project_slug}}/setup.py       |  6 --
 3 files changed, 62 insertions(+), 26 deletions(-)
 delete mode 100644 {{cookiecutter.project_slug}}/setup.py

diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
index 4df143e..ab18cbe 100644
--- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml
+++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
@@ -19,7 +19,7 @@ stages:
   python -V
   python3 -m venv venv
   source venv/bin/activate
-  pip install -U pip setuptools wheel setuptools_scm
+  pip install -U pip setuptools wheel setuptools_scm packaging
   hash -r
   pip freeze
   make install-dev
@@ -30,22 +30,6 @@ stages:
       reports:
         junit: "reports/junit*.xml"
 
-test-py3.6:
-    image: docker.km3net.de/base/python:3.6
-    stage: test
-    script:
-        - *virtualenv_definition
-        - make test
-    <<: *junit_definition
-
-test-py3.7:
-    image: docker.km3net.de/base/python:3.7
-    stage: test
-    script:
-        - *virtualenv_definition
-        - make test
-    <<: *junit_definition
-
 test-py3.8:
     image: docker.km3net.de/base/python:3.8
     stage: test
@@ -137,9 +121,9 @@ pypi:
     stage: release
     cache: {}
     script:
-        - pip install -U twine wheel setuptools_scm
-        - python setup.py sdist
-        - python setup.py bdist_wheel
+        - pip install -U twine wheel setuptools_scm build
+        - python -m build --sdist
+        - python -m build --wheel
         - twine upload dist/*
     only:
         - tags
diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml
index 36dec2d..f2a13bf 100644
--- a/{{cookiecutter.project_slug}}/pyproject.toml
+++ b/{{cookiecutter.project_slug}}/pyproject.toml
@@ -1,5 +1,63 @@
+[project]
+name = "{{cookiecutter.project_slug}}"
+description = "{{cookiecutter.description}}"
+readme = {file = "README.rst", content-type = "text/x-rst"}
+license = MIT
+dynamic = ["version"]
+authors = [
+  {name = "{{cookiecutter.author}}", email ="{{cookiecutter.email}}"}
+]
+maintainers = [
+  {name = "{{cookiecutter.author}}", email ="{{cookiecutter.email}}"}
+]
+requires-python = ">=3.8"
+dependencies = [
+]
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: Developers",
+    "Intended Audience :: Science/Research",
+    "License :: OSI Approved :: MIT License",
+    "Operating System :: OS Independent",
+    "Programming Language :: Python",
+    "Programming Language :: Python :: 3",
+    "Programming Language :: Python :: 3 :: Only",
+    "Programming Language :: Python :: 3.8",
+    "Programming Language :: Python :: 3.9",
+    "Programming Language :: Python :: 3.10",
+    "Programming Language :: Python :: 3.11",
+    "Programming Language :: Python :: 3.12",
+    "Topic :: Scientific/Engineering"
+]
+
 [build-system]
 requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
 
 [tool.setuptools_scm]
 write_to = "src/{{cookiecutter.project_slug}}/version.py"
+
+[project.urls]
+Homepage = "{{cookiecutter.gitlab_repo_url}}"
+Documentation = "{{cookiecutter.gitlab_pages_url}}"
+Repository = "{{cookiecutter.gitlab_repo_url}}"
+Issues = "{{cookiecutter.gitlab_repo_url}}/-/issues"
+Changelog = "{{cookiecutter.gitlab_pages_url}}/changelog.html"
+
+[project.optional-dependencies]
+dev = [
+  "black",
+  "km3net_testdata>=0.2.7",
+  "matplotlib",
+  "memory_profiler",
+  "mock",
+  "numpydoc",
+  "pytest",
+  "pytest-cov",
+  "pytest-watch",
+  "sphinx",
+  "sphinx-autoapi",
+  "sphinx-gallery>=0.1.12",
+  "sphinx_rtd_theme",
+  "sphinxcontrib-versioning",
+  "wheel"
+]
diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py
deleted file mode 100644
index c276fcd..0000000
--- a/{{cookiecutter.project_slug}}/setup.py
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env python
-from setuptools import setup
-
-import setuptools_scm
-
-setup()
-- 
GitLab