Skip to content

Commit

Permalink
Merge pull request #1425 from garberg/repackage_nipap-cli
Browse files Browse the repository at this point in the history
Modernize packaging of nipap-cli
  • Loading branch information
garberg authored Jan 22, 2025
2 parents 9bb7b72 + 539a381 commit 370ce67
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 55 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
fakeroot \
debhelper \
dh-python \
dh-exec \
pybuild-plugin-pyproject \
junit4 \
libldap-dev \
Expand Down Expand Up @@ -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 &
Expand Down
6 changes: 3 additions & 3 deletions nipap-cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}')
Expand Down
1 change: 0 additions & 1 deletion nipap-cli/debian/compat

This file was deleted.

11 changes: 8 additions & 3 deletions nipap-cli/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ Source: nipap-cli
Maintainer: Lukas Garberg <[email protected]>
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.
2 changes: 2 additions & 0 deletions nipap-cli/debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/dh-exec
nipaprc => /etc/.nipaprc
1 change: 1 addition & 0 deletions nipap-cli/debian/nipap-cli.bash-completion
6 changes: 3 additions & 3 deletions nipap-cli/debian/rules
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions nipap-cli/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
40 changes: 40 additions & 0 deletions nipap-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
58 changes: 15 additions & 43 deletions nipap-cli/setup.py
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 370ce67

Please sign in to comment.