Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nipapd: setup.py soft-fail when lacking rst2man #772

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nipap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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=../ --prune
$(PYTHON) setup.py build sdist --dist-dir=../ --prune
rename -f 's/$(PROJECT)-(\d.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*
# build the package
debuild -us -uc
Expand Down
59 changes: 31 additions & 28 deletions nipap/setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
#!/usr/bin/env python

from distutils.command.build import build
from distutils.core import setup

import subprocess
import sys

import nipap

data_files = [
('/etc/nipap/', ['nipap.conf.dist']),
('/usr/sbin/', ['nipapd', 'nipap-passwd']),
('/usr/share/nipap/sql/', [
'sql/upgrade-1-2.plsql',
'sql/upgrade-2-3.plsql',
'sql/upgrade-3-4.plsql',
'sql/upgrade-4-5.plsql',
'sql/upgrade-5-6.plsql',
'sql/functions.plsql',
'sql/triggers.plsql',
'sql/ip_net.plsql'
]),
]

# return all the extra data files
def get_data_files():
# generate man pages using rst2man
try:
subprocess.call(["rst2man", "nipapd.man.rst", "nipapd.8"])
subprocess.call(["rst2man", "nipap-passwd.man.rst", "nipap-passwd.1"])
except OSError as exc:
print >> sys.stderr, "rst2man failed to run:", str(exc)
sys.exit(1)

files = [
('/etc/nipap/', ['nipap.conf.dist']),
('/usr/sbin/', ['nipapd', 'nipap-passwd']),
('/usr/share/nipap/sql/', [
'sql/upgrade-1-2.plsql',
'sql/upgrade-2-3.plsql',
'sql/upgrade-3-4.plsql',
'sql/upgrade-4-5.plsql',
'sql/upgrade-5-6.plsql',
'sql/functions.plsql',
'sql/triggers.plsql',
'sql/ip_net.plsql'
]),
('/usr/share/man/man8/', ['nipapd.8']),
('/usr/share/man/man1/', ['nipap-passwd.1'])
]
class MyBuild(build):
""" Customized build command - build manpages.
"""
def run(self):
try:
print('Generating manpages...')
subprocess.call(["rst2man", "nipapd.man.rst", "nipapd.8"])
subprocess.call(["rst2man", "nipap-passwd.man.rst", "nipap-passwd.1"])
data_files.append(('/usr/share/man/man8/', ['nipapd.8']))
data_files.append(('/usr/share/man/man1/', ['nipap-passwd.1']))

return files
except OSError:
print('Warning: rst2man was not found, skipping the manpage generation.')
build.run(self)


long_desc = open('README.rst').read()
Expand All @@ -52,7 +54,8 @@ def get_data_files():
packages = ['nipap'],
keywords = ['nipap'],
requires = ['ldap', 'sqlite3', 'IPy', 'psycopg2', 'parsedatetime'],
data_files = get_data_files(),
data_files = data_files,
cmdclass = {'build': MyBuild},
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down