diff options
author | Brian Dolbec <dolsen@gentoo.org> | 2015-01-06 12:20:30 -0800 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2015-01-06 13:19:39 -0800 |
commit | 7bfa40a4b350767ec8e8d2812620bb8be6ce48a4 (patch) | |
tree | 073db41c91bb62006a565709f13dd1609022ac99 /gkeys-gen/setup.py | |
parent | py2man/options.py: Add missed '1name' option (diff) | |
download | gentoo-keys-7bfa40a4b350767ec8e8d2812620bb8be6ce48a4.tar.gz gentoo-keys-7bfa40a4b350767ec8e8d2812620bb8be6ce48a4.tar.bz2 gentoo-keys-7bfa40a4b350767ec8e8d2812620bb8be6ce48a4.zip |
gkeys-gen: Setup.py updates for man page generation
Diffstat (limited to 'gkeys-gen/setup.py')
-rwxr-xr-x | gkeys-gen/setup.py | 80 |
1 files changed, 75 insertions, 5 deletions
diff --git a/gkeys-gen/setup.py b/gkeys-gen/setup.py index 063bff1..fc93bf0 100755 --- a/gkeys-gen/setup.py +++ b/gkeys-gen/setup.py @@ -1,11 +1,26 @@ #!/usr/bin/env python + +import collections import os import sys -from distutils.core import setup +from distutils.core import setup, Command +from distutils.command.build import build + from gkeygen import __version__, __license__ +from gkeygen import Gkeys_Map +from gkeygen.actions import Action_Map, Available_Actions + +try: + from py2man import manpages +except ImportError: + print('creating py2man symlink') + os.symlink('../py2man', 'py2man') + from py2man import manpages + + # this affects the names of all the directories we do stuff with sys.path.insert(0, './') @@ -18,10 +33,61 @@ except ImportError: EPREFIX='' +class x_build(build): + """ Build command with extra build_man call. """ + + def run(self): + build.run(self) + self.run_command('build_man') + + +class build_man(Command): + """ Perform substitutions in manpages. """ + + user_options = [ + ] + + def initialize_options(self): + self.build_base = None + + def finalize_options(self): + self.set_undefined_options('build', + ('build_base', 'build_base')) + + def run(self): + # create the main page + basepath = os.path.dirname(__file__) + docpath = os.path.join(basepath, 'doc') + templatepath = os.path.dirname(manpages.__file__) + man = manpages.ManPage('gkey-gen', __version__, None, + docpath, Gkeys_Map['authors']) + man.read_template(templatepath, 'command.template') + man.make_prog(Gkeys_Map) + man.read_template(templatepath, 'sub-command.template') + man.make_subpages(Action_Map, Available_Actions) + + +def get_manpages(): + linguas = os.environ.get('LINGUAS') + if linguas is not None: + linguas = linguas.split() + + for dirpath, dirnames, filenames in os.walk('doc'): + groups = collections.defaultdict(list) + for f in filenames: + fn, suffix = f.rsplit('.', 1) + groups[suffix].append(os.path.join(dirpath, f)) + + topdir = dirpath[len('doc/'):] + if not topdir or linguas is None or topdir in linguas: + for g, mans in groups.items(): + yield [os.path.join('$mandir', topdir, 'man%s' % g), mans] + + setup( - name='gkeygen', + name='gkeys-gen', version=__version__, - description="Gentoo gpg key management key generator", + description="OpenPGP/GPG key generator", author='', author_email='', maintainer='Gentoo-Keys Team', @@ -30,12 +96,16 @@ setup( download_url='', packages=['gkeygen'], scripts=['bin/gkey-gen'], - data_files=( + data_files=list(get_manpages()) + [ (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys-gen.conf']), - ), + ], license=__license__, long_description=open('README.md').read(), keywords='gpg', + cmdclass = { + 'build': x_build, + 'build_man': build_man, + }, classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers, Users', |