aboutsummaryrefslogtreecommitdiff
blob: fdb8e182f55486670bf96d83c11c014d67b5ab32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python


import os
import sys

from distutils.core import setup, Command
from distutils.command.build import build
from glob import glob

from gkeys import __version__, __license__

from gkeys import Gkeys_Map
from gkeys.action_map 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, './')

#__version__ = os.getenv('VERSION', default='9999')

# Load EPREFIX from Portage, fall back to the empty string if it fails
try:
    from portage.const import EPREFIX
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('gkeys', __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)


setup(
    name='gkeys',
    version=__version__,
    description="Gentoo gpg key management and Python interface to gpg",
    author='',
    author_email='',
    maintainer='Gentoo-Keys Team',
    maintainer_email='gkeys@gentoo.org',
    url="https://wiki.gentoo.org/wiki/Project:Gentoo-keys",
    download_url='',
    packages=['gkeys'],
    scripts=['bin/gkeys'],
    data_files=[
        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys.conf']),
        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys.conf.sample']),
        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), glob('doc/*')),
        ],
    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',
        'License :: OSI Approved :: GPLv2 License',
        'Programming Language :: Python :: 2.7, 3.3, 3.4, +',
        'Operating System :: OS Independent',
        'Topic :: Security :: Cryptography',
    ],
)