Repository: ionos-cloud/dim (language: python)

Issue:
move to pyproject.toml
Python decided that setup.py isn't supported anymore. The "new" way is to use pyproject.toml files to specify how a project should look like.

This also drops a lot of things that were possible with setup.py like providing scripts directly. This is not possible anymore and needs to be implemented some other way. Python says via a package manager.

So this is how I get things working at least a little bit.

To get manage_dim and manage_db working again I merged it all into a dim CLI tool. So things need to be called `dim db ...`.


Discussion / hints:
@parsa97 can you please take a look.
Thank you for your contribution, @Gibheer.
-    Please rebase this branch with master.
-    Split the CLI changes into another PR and update the documentation.
-    The change in the command line interface is not something easy to consider; we may do this in the next release.
-    Limit this PR to only adding pyproject.toml and keep setup.py. We are already using setup.py and may consider removing it in the future.

Fix patch:
diff --git a/dim/dim/cli.py b/dim/dim/cli.py
new file mode 100644
index 00000000..4ca835b7
--- /dev/null
+++ b/dim/dim/cli.py
@@ -0,0 +1,7 @@
+import click
+import dim
+from flask.cli import FlaskGroup
+
+@click.group(cls=FlaskGroup, create_app=dim.create_app)
+def cli():
+    print("For output check your syslog output")
diff --git a/dim/pyproject.toml b/dim/pyproject.toml
new file mode 100644
index 00000000..4ad3f2d0
--- /dev/null
+++ b/dim/pyproject.toml
@@ -0,0 +1,53 @@
+[project]
+name = "dimserver"
+version = "5.0.2"
+maintainers = [
+  { name = "zerimond" },
+]
+description = "DNS and IP management Python server"
+requires-python = ">=3.9"
+dependencies=[
+    "mysqlclient>=1.4.6",
+    "SQLAlchemy~=1.4",
+    "ldap3~=2.9",
+    "Flask~=2.1",
+    "Flask-SQLAlchemy~=2.5",
+    "Jinja2~=3.1",
+    "dnspython~=2.1,!=2.2.0",
+    "requests~=2.27",
+    "pycryptodome~=3.14",
+    "gunicorn>=21",
+]
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: Developers",
+    "Programming Language :: Python :: 3",
+    "License :: OSI Approved :: MIT License",
+    "Operating System :: OS Independent",
+]
+
+[project.optional-dependencies]
+docs = [
+    "nose~=1.3",
+    "nose-ignore-docstring~=0.2",
+    "pytest~=7.1",
+    "pytest-cov~=3.0",
+    "Sphinx~=4.4",
+]
+
+[project.urls]
+Homepage = "https://github.com/ionos-cloud/dim"
+Issues = "https://github.com/ionos-cloud/dim/issues"
+
+[project.scripts]
+dim = "dim.cli:cli"
+
+[tool.setuptools.packages.find]
+exclude = ["doc", "etc"]
+
+
+[tool.setuptools]
+script-files = ["report", "manage_db", "manage_dim"]
+
+[tool.setuptools.package-data]
+dim = ["sql/*.sql", "../etc/*"]
diff --git a/dim/setup.cfg b/dim/setup.cfg
deleted file mode 100644
index cec53eb6..00000000
--- a/dim/setup.cfg
+++ /dev/null
@@ -1,6 +0,0 @@
-[versioneer]
-VCS = git
-style = git-describe
-versionfile_source = dim/_version.py
-versionfile_build = dim/_version.py
-tag_prefix =
diff --git a/dim/setup.py b/dim/setup.py
deleted file mode 100644
index 13d15440..00000000
--- a/dim/setup.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from distutils.core import setup
-from dim import version
-
-setup(name='dim',
-      version=version.VERSION,
-      packages=['dim', 'dim.models'],
-      package_data={'dim': ['sql/*.sql']},
-      scripts=['report', 'manage_db', 'manage_dim'])
diff --git a/dimclient/pyproject.toml b/dimclient/pyproject.toml
new file mode 100644
index 00000000..edbde5fa
--- /dev/null
+++ b/dimclient/pyproject.toml
@@ -0,0 +1,20 @@
+[project]
+name = "dimclient"
+version = "1.0.1"
+maintainers = [
+  { name = "zerimond" },
+]
+description = "DNS and IP management Python library"
+readme = "README.md"
+requires-python = ">=3.6"
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: Developers",
+    "Programming Language :: Python :: 3",
+    "License :: OSI Approved :: MIT License",
+    "Operating System :: OS Independent",
+]
+
+[project.urls]
+Homepage = "https://github.com/ionos-cloud/dim"
+Issues = "https://github.com/ionos-cloud/dim/issues"
diff --git a/dimclient/setup.cfg b/dimclient/setup.cfg
deleted file mode 100644
index 700c19b7..00000000
--- a/dimclient/setup.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-[easy_install]
-
diff --git a/dimclient/setup.py b/dimclient/setup.py
deleted file mode 100644
index a68aca48..00000000
--- a/dimclient/setup.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from setuptools import setup
-from dimclient import version
-
-setup(name='dimclient',
-      version=version.VERSION,
-      packages=['dimclient'])
diff --git a/ndcli/pyproject.toml b/ndcli/pyproject.toml
new file mode 100644
index 00000000..63a414fb
--- /dev/null
+++ b/ndcli/pyproject.toml
@@ -0,0 +1,34 @@
+[project]
+name = "dimclient-cli"
+version = "5.0.2"
+maintainers = [
+  { name = "zerimond" },
+]
+description = "DNS and IP management Python CLI client"
+readme = "README.md"
+dependencies = [
+  "dimclient",
+  "python-dateutil>=1.4.1",
+  "dnspython>=1.12.0,!=2.2.0",
+]
+requires-python = ">=3.6"
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: System Administrators",
+    "Programming Language :: Python :: 3",
+    "License :: OSI Approved :: MIT License",
+    "Operating System :: OS Independent",
+]
+
+[project.optional-dependencies]
+docs = [
+    "Sphinx~=4.4",
+    "hypothesis~=5.6.0",
+]
+
+[project.scripts]
+ndcli = "dimcli:main"
+
+[project.urls]
+Homepage = "https://github.com/ionos-cloud/dim"
+Issues = "https://github.com/ionos-cloud/dim/issues"
diff --git a/ndcli/setup.py b/ndcli/setup.py
deleted file mode 100644
index a3a4cfd9..00000000
--- a/ndcli/setup.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from setuptools import setup
-from dimcli import version
-
-setup(name='ndcli',
-      version=version.VERSION,
-      scripts=['ndcli'],
-      install_requires=['dimclient>=0.4.1',
-                        'python-dateutil',
-                        'dnspython'],
-      packages=['dimcli'])


Test patch:
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index 9076f056..336106a0 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -36,7 +36,7 @@ jobs:
       - name: Check out repository code
         uses: actions/checkout@v3
       - name: Prepare virtual environment
-        run: make install-dev
+        run: make install-test
         working-directory: dim-testsuite
       - name: Create DIM configuration directory
         run: mkdir -p /etc/dim
diff --git a/dim-testsuite/Makefile b/dim-testsuite/Makefile
index f57226ee..0d4345a5 100644
--- a/dim-testsuite/Makefile
+++ b/dim-testsuite/Makefile
@@ -49,6 +49,10 @@ install-dev: install-deps-local-editable
 	${VPIP} install -r ../dim/requirements-dev.txt
 	${VPIP} install -r ../ndcli/requirements-dev.txt
 
+install-test: install
+	${VPIP} install -r ../dim/requirements-dev.txt
+	${VPIP} install -r ../ndcli/requirements-dev.txt
+
 db-clear:
 	FLASK_APP=${FLASK_APP} ${VDIR}/bin/flask db clear