From 29ece1af0b9601cf182338d706789276432a6f93 Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Tue, 22 Mar 2022 15:19:09 +0100
Subject: [PATCH] Restructure and modernise

---
 {{cookiecutter.project_slug}}/.coveragerc     |  5 +-
 {{cookiecutter.project_slug}}/.gitignore      |  2 +-
 {{cookiecutter.project_slug}}/Makefile        | 13 +--
 {{cookiecutter.project_slug}}/doc/conf.py     |  2 +-
 {{cookiecutter.project_slug}}/pyproject.toml  |  2 +-
 .../requirements/dev.txt                      | 15 ---
 .../requirements/install.txt                  |  1 -
 {{cookiecutter.project_slug}}/setup.cfg       | 98 +++++++++++++++++++
 {{cookiecutter.project_slug}}/setup.py        | 41 +-------
 .../{{cookiecutter.project_slug}}/__init__.py |  0
 .../{{cookiecutter.project_slug}}/calc.py     |  0
 .../{{cookiecutter.project_slug}}/utils.py    |  0
 12 files changed, 108 insertions(+), 71 deletions(-)
 delete mode 100644 {{cookiecutter.project_slug}}/requirements/dev.txt
 delete mode 100644 {{cookiecutter.project_slug}}/requirements/install.txt
 create mode 100644 {{cookiecutter.project_slug}}/setup.cfg
 rename {{cookiecutter.project_slug}}/{ => src}/{{cookiecutter.project_slug}}/__init__.py (100%)
 rename {{cookiecutter.project_slug}}/{ => src}/{{cookiecutter.project_slug}}/calc.py (100%)
 rename {{cookiecutter.project_slug}}/{ => src}/{{cookiecutter.project_slug}}/utils.py (100%)

diff --git a/{{cookiecutter.project_slug}}/.coveragerc b/{{cookiecutter.project_slug}}/.coveragerc
index 8b68000..6e4efbc 100644
--- a/{{cookiecutter.project_slug}}/.coveragerc
+++ b/{{cookiecutter.project_slug}}/.coveragerc
@@ -2,11 +2,8 @@
 source = {{cookiecutter.project_slug}}
 
 [report]
-include =
-    {{cookiecutter.project_slug}}/*
 omit =
-    tests/*
-    {{cookiecutter.project_slug}}/version.py
+    src/{{cookiecutter.project_slug}}/version.py
 exclude_lines =
     pragma: no cover
     raise AssertionError
diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore
index 1a35804..db3aa84 100644
--- a/{{cookiecutter.project_slug}}/.gitignore
+++ b/{{cookiecutter.project_slug}}/.gitignore
@@ -4,7 +4,7 @@ __pycache__/
 *.pyxbldc
 
 # Version info
-{{cookiecutter.project_slug}}/version.py
+src/{{cookiecutter.project_slug}}/version.py
 
 # Build stuff
 build/
diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile
index 3b920bf..734df42 100644
--- a/{{cookiecutter.project_slug}}/Makefile
+++ b/{{cookiecutter.project_slug}}/Makefile
@@ -1,5 +1,3 @@
-PKGNAME={{cookiecutter.project_slug}}
-
 install:
 	pip install .
 
@@ -10,10 +8,10 @@ clean:
 	python setup.py clean --all
 
 test:
-	py.test --junitxml=./reports/junit.xml -o junit_suite_name=$(PKGNAME) tests
+	py.test --junitxml=./reports/junit.xml -o junit_suite_name={{cookiecutter.project_slug}} tests
 
 test-cov:
-	py.test --cov ./$(PKGNAME) --cov-report term-missing --cov-report xml:reports/coverage.xml --cov-report html:reports/coverage tests
+	py.test --cov src/{{cookiecutter.project_slug}} --cov-report term-missing --cov-report xml:reports/coverage.xml --cov-report html:reports/coverage tests
 
 test-loop:
 	py.test tests
@@ -30,11 +28,9 @@ docstyle:
 lint:
 	py.test --pylint
 
-dependencies:
-	pip install -Ur requirements.txt
-
 .PHONY: black
 black:
+	black --exclude 'version.py' src/{{cookiecutter.project_slug}}
 	black examples
 	black tests
 	black doc/conf.py
@@ -42,10 +38,11 @@ black:
 
 .PHONY: black-check
 black-check:
+	black --check --exclude 'version.py' src/{{cookiecutter.project_slug}}
 	black --check examples
 	black --check tests
 	black --check doc/conf.py
 	black --check setup.py
 
 
-.PHONY: all clean install install-dev test  test-nocov flake8 pep8 dependencies docstyle black black-check
+.PHONY: all clean install install-dev test  test-nocov flake8 pep8 docstyle black black-check
diff --git a/{{cookiecutter.project_slug}}/doc/conf.py b/{{cookiecutter.project_slug}}/doc/conf.py
index 17611f8..b25bab7 100644
--- a/{{cookiecutter.project_slug}}/doc/conf.py
+++ b/{{cookiecutter.project_slug}}/doc/conf.py
@@ -48,7 +48,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'version.py']
 
 # AutoAPI
 autoapi_type = "python"
-autoapi_dirs = ['../{{cookiecutter.project_slug}}']
+autoapi_dirs = ['../src/{{cookiecutter.project_slug}}']
 autoapi_options = ["members", "undoc-members", "show-module-summary"]
 autoapi_include_summaries = True
 
diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml
index f4fcb17..36dec2d 100644
--- a/{{cookiecutter.project_slug}}/pyproject.toml
+++ b/{{cookiecutter.project_slug}}/pyproject.toml
@@ -2,4 +2,4 @@
 requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
 
 [tool.setuptools_scm]
-write_to = "{{cookiecutter.project_slug}}/version.py"
+write_to = "src/{{cookiecutter.project_slug}}/version.py"
diff --git a/{{cookiecutter.project_slug}}/requirements/dev.txt b/{{cookiecutter.project_slug}}/requirements/dev.txt
deleted file mode 100644
index 924a585..0000000
--- a/{{cookiecutter.project_slug}}/requirements/dev.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-black
-matplotlib
-numpydoc
-pillow
-pytest
-pytest-cov
-pytest-flake8
-pytest-pylint
-pytest-watch
-sphinx
-sphinx-autoapi
-sphinx-gallery>=0.1.12
-sphinx_rtd_theme
-sphinxcontrib-versioning
-wheel
diff --git a/{{cookiecutter.project_slug}}/requirements/install.txt b/{{cookiecutter.project_slug}}/requirements/install.txt
deleted file mode 100644
index cba8d88..0000000
--- a/{{cookiecutter.project_slug}}/requirements/install.txt
+++ /dev/null
@@ -1 +0,0 @@
-setuptools_scm
diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg
new file mode 100644
index 0000000..4cd424a
--- /dev/null
+++ b/{{cookiecutter.project_slug}}/setup.cfg
@@ -0,0 +1,98 @@
+[metadata]
+name = {{cookiecutter.project_slug}}
+description = {{cookiecutter.description}}
+long_description = file: README.rst
+long_description_content_type = text/x-rst
+url = {{cookiecutter.gitlab_repo_path}}
+author = {{cookiecutter.author}}
+author_email = {{cookiecutter.email}}
+maintainer = {{cookiecutter.author}}
+maintainer_email = {{cookiecutter.email}}
+license = MIT
+license_file = LICENSE
+classifiers =
+    Development Status :: 5 - Production/Stable
+    Intended Audience :: Developers
+    Intended Audience :: Science/Research
+    License :: OSI Approved :: BSD License
+    Operating System :: OS Independent
+    Programming Language :: Python
+    Programming Language :: Python :: 3
+    Programming Language :: Python :: 3 :: Only
+    Programming Language :: Python :: 3.6
+    Programming Language :: Python :: 3.7
+    Programming Language :: Python :: 3.8
+    Programming Language :: Python :: 3.9
+    Programming Language :: Python :: 3.10
+    Topic :: Scientific/Engineering
+keywords =
+    neutrino
+    astroparticle
+    physics
+    HEP
+
+[options]
+packages = find:
+install_requires =
+    setuptools_scm
+python_requires = >=3.6
+include_package_data = True
+package_dir =
+    =src
+
+[options.packages.find]
+where = src
+
+[options.extras_require]
+all =
+    black
+    matplotlib
+    numpydoc
+    pillow
+    pytest
+    pytest-cov
+    pytest-flake8
+    pytest-pylint
+    pytest-watch
+    sphinx
+    sphinx-autoapi
+    sphinx-gallery>=0.1.12
+    sphinx_rtd_theme
+    sphinxcontrib-versioning
+    wheel
+dev =
+    black
+    matplotlib
+    numpydoc
+    pillow
+    pytest
+    pytest-cov
+    pytest-flake8
+    pytest-pylint
+    pytest-watch
+    sphinx
+    sphinx-autoapi
+    sphinx-gallery>=0.1.12
+    sphinx_rtd_theme
+    sphinxcontrib-versioning
+    wheel
+
+[options.package_data]
+* = *.py.typed
+
+[bdist_wheel]
+universal = 1
+
+[tool:pytest]
+junit_family = xunit2
+addopts = -vv -rs -Wd
+testpaths =
+    tests
+
+[check-manifest]
+ignore =
+    src/{{cookiecutter.project_slug}}/version.py
+
+[tool:isort]
+profile = black
+multi_line_output = 3
diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py
index 20f24c7..c823345 100644
--- a/{{cookiecutter.project_slug}}/setup.py
+++ b/{{cookiecutter.project_slug}}/setup.py
@@ -1,43 +1,4 @@
 #!/usr/bin/env python
-# Filename: setup.py
-"""
-The {{cookiecutter.project_slug}} setup script.
-
-"""
 from setuptools import setup
-import os
-
-
-def read_requirements(kind):
-    """Return a list of stripped lines from a file"""
-    with open(os.path.join("requirements", kind + ".txt")) as fobj:
-        return [l.strip() for l in fobj.readlines()]
-
-
-try:
-    with open("README.rst") as fh:
-        long_description = fh.read()
-except UnicodeDecodeError:
-    long_description = "{{cookiecutter.description}}"
 
-setup(
-    name='{{cookiecutter.project_slug}}',
-    url='{{cookiecutter.gitlab_repo_path}}',
-    description='{{cookiecutter.description}}',
-    long_description=long_description,
-    author='{{cookiecutter.author}}',
-    author_email='{{cookiecutter.email}}',
-    packages=['{{cookiecutter.project_slug}}'],
-    include_package_data=True,
-    platforms='any',
-    setup_requires=['setuptools_scm'],
-    use_scm_version=True,
-    python_requires='>=3.6',
-    install_requires=read_requirements("install"),
-    extras_require={kind: read_requirements(kind) for kind in ["dev"]},
-    classifiers=[
-        'Intended Audience :: Developers',
-        'Intended Audience :: Science/Research',
-        'Programming Language :: Python',
-    ],
-)
+setup()
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py
similarity index 100%
rename from {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py
rename to {{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/calc.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/calc.py
similarity index 100%
rename from {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/calc.py
rename to {{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/calc.py
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/utils.py
similarity index 100%
rename from {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils.py
rename to {{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/utils.py
-- 
GitLab