From 4d9b9a50c46fc596f81d29f6a1c76a5cc469d7c8 Mon Sep 17 00:00:00 2001
From: Andreas Dedner <a.s.dedner@warwick.ac.uk>
Date: Fri, 18 Dec 2020 21:34:40 +0000
Subject: [PATCH] make it possible to use setup.py without having an installed
 dune-common python package. This requires having the PYTHONPATH set as it is
 now done in dune-common/bin/dunepackaging.py

---
 .gitignore         |  4 ++++
 dune-istl.pc.in    |  4 ++--
 dune.module        |  4 ++++
 pyproject.toml     |  3 +++
 python/setup.py.in | 14 +++++++++-----
 setup.py           |  6 ++++++
 6 files changed, 28 insertions(+), 7 deletions(-)
 create mode 100644 pyproject.toml
 create mode 100644 setup.py

diff --git a/.gitignore b/.gitignore
index 64201abe..71a975cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,6 @@
 *~
 /build*/
+# ignore files generated during python setup.py sdist
+MANIFEST
+_skbuild/
+dist
diff --git a/dune-istl.pc.in b/dune-istl.pc.in
index 352eb06e..6b456fa5 100644
--- a/dune-istl.pc.in
+++ b/dune-istl.pc.in
@@ -8,8 +8,8 @@ DEPENDENCIES=@REQUIRES@
 
 Name: @PACKAGE_NAME@
 Version: @VERSION@
-Description: Dune (Distributed and Unified Numerics Environment) istl module
-URL: http://dune-project.org/
+Description: @DESCRIPTION@
+URL: @URL@
 Requires: ${DEPENDENCIES}
 Libs:
 Cflags: -I${includedir}
diff --git a/dune.module b/dune.module
index 62f6dbee..293eebc5 100644
--- a/dune.module
+++ b/dune.module
@@ -1,5 +1,9 @@
 Module: dune-istl
 Version: 2.8-git
+Author: The Dune Core developers
 Maintainer: dune-devel@lists.dune-project.org
+Description: Iterative solver template library which provides generic sparse matrix/vector classes and a variety of solvers based on these classes
+URL: https://gitlab.dune-project.org/core/dune-istl
+Python-Requires:
 Depends: dune-common (>= 2.8)
 Whitespace-Hook: Yes
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..51561aa8
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ['setuptools', 'wheel', 'scikit-build', 'cmake', 'ninja', 'requests', 'dune-common>=2.8.0.dev0']
+build-backend = 'setuptools.build_meta'
diff --git a/python/setup.py.in b/python/setup.py.in
index da93243b..dd784ccf 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -1,11 +1,15 @@
 from setuptools import setup, find_packages
 
-setup(name="dune.istl",
+pkg = [m for m in "${ProjectPythonRequires}".split(' ') if "dune" not in m]
+
+setup(name="${ProjectName}",
     namespace_packages=['dune'],
-    description="Python lib for dune: dune-alugrid library",
-    version="${DUNE_ISTL_VERSION}",
-    author="Andreas Dedner and Martin Nolte",
+    description="${ProjectDescription}",
+    version="${ProjectVersionString}",
+    author="${ProjectAuthor}",
+    author_email="${ProjectMaintainerEmail}",
     packages = find_packages(),
     zip_safe = 0,
-    package_data = {'': ['*.so']}
+    package_data = {'': ['*.so']},
+    install_requires = pkg
   )
diff --git a/setup.py b/setup.py
new file mode 100644
index 00000000..85afc751
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,6 @@
+try:
+    from dune.packagemetadata import metaData
+except ImportError:
+    from packagemetadata import metaData
+from skbuild import setup
+setup(**metaData()[1])
-- 
GitLab