Skip to content

Commit

Permalink
cli: Change build system to setuptools
Browse files Browse the repository at this point in the history
  • Loading branch information
garberg committed Jan 22, 2025
1 parent b8fcb9f commit 152c3d7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 43 deletions.
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"
57 changes: 14 additions & 43 deletions nipap-cli/setup.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,34 @@
#!/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 152c3d7

Please sign in to comment.