From 52f2a09753d882a819af21648d1a93255e426741 Mon Sep 17 00:00:00 2001 From: Lukas Garberg Date: Wed, 22 Jan 2025 10:09:22 +0100 Subject: [PATCH] whoisd: Modernize packaging --- whoisd/Makefile | 6 +++--- whoisd/debian/compat | 1 - whoisd/debian/control | 9 ++++++--- whoisd/debian/init | 2 +- whoisd/debian/install | 1 + whoisd/debian/source/format | 1 + whoisd/pyproject.toml | 39 +++++++++++++++++++++++++++++++++++++ whoisd/setup.py | 37 ++++++++++------------------------- 8 files changed, 61 insertions(+), 35 deletions(-) delete mode 100644 whoisd/debian/compat create mode 100644 whoisd/debian/install create mode 100644 whoisd/debian/source/format create mode 100644 whoisd/pyproject.toml diff --git a/whoisd/Makefile b/whoisd/Makefile index f1d7ba22b..669a93b74 100644 --- a/whoisd/Makefile +++ b/whoisd/Makefile @@ -26,8 +26,8 @@ buildrpm: builddeb: # build the source package in the parent directory # then rename it to project_version.orig.tar.gz - $(PYTHON) setup.py sdist --dist-dir=../ - rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* + $(PYTHON) -m build --sdist --outdir=../ + rename -f 's/nipap_whoisd-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* # build the package debuild -us -uc @@ -45,7 +45,7 @@ clean: .pc/ debian/$(PROJECT).debhelper.log debian/$(PROJECT).postinst.debhelper \ debian/$(PROJECT).prerm.debhelper debian/$(PROJECT).postrm.debhelper \ debian/$(PROJECT).substvars nipap-whoisd.8 debian/.debhelper \ - debian/debhelper-build-stamp + debian/debhelper-build-stamp nipap_whoisd.egg-info find . -name '*.pyc' -delete VER := $(shell head -n1 ../NEWS | awk '{print $$2}') diff --git a/whoisd/debian/compat b/whoisd/debian/compat deleted file mode 100644 index f599e28b8..000000000 --- a/whoisd/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/whoisd/debian/control b/whoisd/debian/control index 1af50d12c..a837c71cd 100644 --- a/whoisd/debian/control +++ b/whoisd/debian/control @@ -2,12 +2,15 @@ Source: nipap-whoisd Maintainer: Kristian Larsson Section: python Priority: optional -Build-Depends: python3 (>= 3.6), debhelper (>= 10), dh-python -Standards-Version: 4.4.0 +Build-Depends: debhelper-compat (= 13), + dh-python, + python3-all, + python3-setuptools +Standards-Version: 4.6.1 Package: nipap-whoisd Architecture: all -Depends: ${misc:Depends}, python3 (>= 3.6), python3-pynipap +Depends: ${misc:Depends}, ${python3:Depends} Description: Neat IP Address Planner The NIPAP whois daemon provides a whois-style interface for querying data in the NIPAP backend. It receives whois queries, translates these into search diff --git a/whoisd/debian/init b/whoisd/debian/init index 724f83680..17d03237f 100755 --- a/whoisd/debian/init +++ b/whoisd/debian/init @@ -11,7 +11,7 @@ set -e # Short-Description: NIPAP whois daemon ### END INIT INFO -DAEMON=/usr/sbin/nipap-whoisd +DAEMON=/usr/bin/nipap-whoisd CONFIGFILE=/etc/nipap/whoisd.conf NAME=nipap-whoisd LONGNAME="NIPAP whois daemon" diff --git a/whoisd/debian/install b/whoisd/debian/install new file mode 100644 index 000000000..c5947f346 --- /dev/null +++ b/whoisd/debian/install @@ -0,0 +1 @@ +whoisd.conf.dist etc/nipap diff --git a/whoisd/debian/source/format b/whoisd/debian/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/whoisd/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/whoisd/pyproject.toml b/whoisd/pyproject.toml new file mode 100644 index 000000000..ee9a523c4 --- /dev/null +++ b/whoisd/pyproject.toml @@ -0,0 +1,39 @@ +[project] +name = "nipap-whoisd" +dynamic = ["version", "description"] +readme = "README.rst" +license = {text = "MIT"} +classifiers = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Intended Audience :: Telecommunications Industry', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3', + 'Topic :: Internet' +] +keywords = ["nipap"] +dependencies = [ + "pynipap" +] + +[project.urls] +Homepage = "http://SpriteLink.github.io/NIPAP" + +[tool.setuptools.dynamic] +version = {attr = "nipap_whoisd.__version__"} + +[build-system] +requires = [ + "setuptools", + # Need to be pinned to 0.20.1 in Ubuntu 24.04 as using the latest 0.21.2 + # gives a diff during .deb package build. Unfortunately the files are + # generated twice - first once in a virtualenv (using the version specified + # here) and then once without a virtualenv using the one from the system. + # There two runs produce different outputs (wich they shouldn't) causing a + # diff and the package utils to b0rk out. + "docutils==0.20.1" +] +build-backend = "setuptools.build_meta" diff --git a/whoisd/setup.py b/whoisd/setup.py index d1b73c8aa..9314f791a 100644 --- a/whoisd/setup.py +++ b/whoisd/setup.py @@ -1,24 +1,25 @@ #!/usr/bin/env python3 -from distutils.core import setup -import subprocess +from setuptools import setup import sys -import nipap_whoisd +from docutils.core import publish_cmdline +from docutils.writers import manpage + # return all the extra data files def get_data_files(): # generate man pages using rst2man try: - subprocess.call(["rst2man", "nipap-whoisd.man.rst", "nipap-whoisd.8"]) - except OSError as exc: - print("rst2man failed to run: {}".format(str(exc)), file=sys.stderr) + publish_cmdline(writer=manpage.Writer(), argv=["nipap-whoisd.man.rst", "nipap-whoisd.8"]) + except Exception as exc: + print("Failed to compile man file: {}".format(str(exc)), file=sys.stderr) sys.exit(1) files = [ - ('/etc/nipap/', ['whoisd.conf.dist']), - ('/usr/sbin/', ['nipap-whoisd']), - ('/usr/share/man/man8/', ['nipap-whoisd.8']) + ('share/nipap/', ['whoisd.conf.dist']), + ('bin/', ['nipap-whoisd']), + ('share/man/man8/', ['nipap-whoisd.8']) ] return files @@ -28,26 +29,8 @@ def get_data_files(): short_desc = long_desc.split('\n')[0].split(' - ')[1].strip() setup( - name = 'nipap-whoisd', - version = nipap_whoisd.__version__, description = short_desc, long_description = long_desc, - author = nipap_whoisd.__author__, - author_email = nipap_whoisd.__author_email__, - license = nipap_whoisd.__license__, - url = nipap_whoisd.__url__, py_modules = ['nipap_whoisd'], - keywords = ['nipap-whoisd'], - requires = ['pynipap'], data_files = get_data_files(), - classifiers = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Intended Audience :: Telecommunications Industry', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 2.6' - ] )