diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7d96dded..64161c40a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: fakeroot \ debhelper \ dh-python \ + dh-exec \ pybuild-plugin-pyproject \ junit4 \ libldap-dev \ @@ -94,8 +95,8 @@ jobs: sudo nipap-passwd add -u readonly -p gottatest --readonly -n "Read-only user for running unit tests" # install pynipap cd pynipap; sudo -H pip3 install --break-system-packages -I .; cd .. - # install nipap-cli dependencies - sudo -H pip3 install --break-system-packages -r nipap-cli/requirements.txt + # install nipap-cli + sudo -H pip3 install --break-system-packages ./nipap-cli/ # start nipap backend nipapd --no-pid-file -c /etc/nipap/nipap.conf -df 2>&1 > /tmp/nipap.log & diff --git a/nipap-cli/Makefile b/nipap-cli/Makefile index 99aad8a5b..998e32132 100644 --- a/nipap-cli/Makefile +++ b/nipap-cli/Makefile @@ -27,8 +27,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_cli-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* # build the package debuild -us -uc @@ -45,7 +45,7 @@ clean: rm -rf .pybuild/ MANIFEST dist/ debian/tmp debian/$(PROJECT) debian/files \ .pc/ debian/$(PROJECT).debhelper.log debian/$(PROJECT).postinst.debhelper \ debian/$(PROJECT).prerm.debhelper debian/$(PROJECT).substvars nipap.1 \ - debian/.debhelper debian/debhelper-build-stamp + debian/.debhelper debian/debhelper-build-stamp nipap_cli.egg-info find . -name '*.pyc' -delete VER := $(shell head -n1 ../NEWS | awk '{print $$2}') diff --git a/nipap-cli/debian/compat b/nipap-cli/debian/compat deleted file mode 100644 index f599e28b8..000000000 --- a/nipap-cli/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/nipap-cli/debian/control b/nipap-cli/debian/control index 09397b86d..e6d0e2b08 100644 --- a/nipap-cli/debian/control +++ b/nipap-cli/debian/control @@ -2,12 +2,17 @@ Source: nipap-cli Maintainer: Lukas Garberg Section: python Priority: optional -Build-Depends: python3 (>= 3.1), dh-python, debhelper (>= 10), python3-setuptools -Standards-Version: 4.4.0 +Build-Depends: debhelper-compat (= 13), + dh-python, + dh-exec, + python3-all, + python3-setuptools, + bash-completion +Standards-Version: 4.6.1 Package: nipap-cli Architecture: all -Depends: ${misc:Depends}, python3 (>= 3.1), python3-ipy, python3-pynipap +Depends: ${misc:Depends}, ${python3:Depends} Description: Neat IP Address Planner The Neat IP Address Planner, NIPAP, is a system built for efficiently managing large amounts of IP addresses. This is the shell command. diff --git a/nipap-cli/debian/install b/nipap-cli/debian/install new file mode 100755 index 000000000..e6a3f40ff --- /dev/null +++ b/nipap-cli/debian/install @@ -0,0 +1,2 @@ +#!/usr/bin/dh-exec +nipaprc => /etc/.nipaprc diff --git a/nipap-cli/debian/nipap-cli.bash-completion b/nipap-cli/debian/nipap-cli.bash-completion new file mode 120000 index 000000000..41b76366a --- /dev/null +++ b/nipap-cli/debian/nipap-cli.bash-completion @@ -0,0 +1 @@ +../bash_complete \ No newline at end of file diff --git a/nipap-cli/debian/rules b/nipap-cli/debian/rules index 130a197a9..b6a6052c5 100755 --- a/nipap-cli/debian/rules +++ b/nipap-cli/debian/rules @@ -1,8 +1,8 @@ #!/usr/bin/make -f #export DH_VERBOSE=1 -export PYBUILD_NAME=nipap-cli -export PYBUILD_INSTALL_ARGS=--install-lib usr/lib/python3/dist-packages/ +#export PYBUILD_NAME=nipap-cli +#export PYBUILD_INSTALL_ARGS=--install-lib usr/lib/python3/dist-packages/ %: - dh $@ --with python3 --buildsystem=pybuild + dh $@ --with python3 --buildsystem=pybuild --with bash-completion diff --git a/nipap-cli/debian/source/format b/nipap-cli/debian/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/nipap-cli/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/nipap-cli/pyproject.toml b/nipap-cli/pyproject.toml new file mode 100644 index 000000000..2df0e641f --- /dev/null +++ b/nipap-cli/pyproject.toml @@ -0,0 +1,40 @@ +[project] +name = "nipap-cli" +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", + "IPy==1.01" +] + +[project.urls] +Homepage = "http://SpriteLink.github.io/NIPAP" + +[tool.setuptools.dynamic] +version = {attr = "nipap_cli.__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/nipap-cli/setup.py b/nipap-cli/setup.py index dcb2415d7..dc7427f18 100755 --- a/nipap-cli/setup.py +++ b/nipap-cli/setup.py @@ -1,63 +1,35 @@ #!/usr/bin/env python3 -from distutils.core import setup -import subprocess +from docutils.core import publish_cmdline +from docutils.writers import manpage +from setuptools import setup import sys -import nipap_cli - # return all the extra data files def get_data_files(): - # This is a bloody hack to circumvent a lack of feature with Python distutils. - # Files specified in the data_files list cannot be renamed upon installation - # and we don't want to keep two copies of the .nipaprc file in git - import shutil - shutil.copyfile('nipaprc', '.nipaprc') - - # generate man pages using rst2man + # generate man pages from .rst-file try: - subprocess.call(["rst2man", "nipap.man.rst", "nipap.1"]) - except OSError as exc: - print("rst2man failed to run:", str(exc), file=sys.stderr) + publish_cmdline(writer=manpage.Writer(), argv=["nipap.man.rst", "nipap.1"]) + except Exception as exc: + print("rst2man failed to run: %s" % str(exc), file=sys.stderr) sys.exit(1) files = [ - ('/etc/skel/', ['.nipaprc']), - ('/usr/bin/', ['helper-nipap', 'nipap']), - ('/usr/share/doc/nipap-cli/', ['bash_complete', 'nipaprc']), - ('/usr/share/man/man1/', ['nipap.1']) + ('bin/', ['helper-nipap', 'nipap']), + ('share/doc/nipap-cli/', ['bash_complete', 'nipaprc']), + ('share/man/man1/', ['nipap.1']) ] return files +long_desc = open('README.rst').read() +short_desc = long_desc.split('\n')[0] + setup( - name = 'nipap-cli', - version = nipap_cli.__version__, - description = "NIPAP shell command", - long_description = "A shell command to interact with NIPAP.", - author = nipap_cli.__author__, - author_email = nipap_cli.__author_email__, - license = nipap_cli.__license__, - url = nipap_cli.__url__, + description = short_desc, + long_description = long_desc, packages = ['nipap_cli'], - keywords = ['nipap_cli'], - requires = ['IPy', '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 :: 3 :: Only', - 'Topic :: Internet' - ] ) - -# Remove the .nipaprc put the by the above hack. -import os -os.remove('.nipaprc')