aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
blob: 33c92618052d4e2eaf19ce541821829da9287fe2 (plain) (blame)
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
#!/usr/bin/python
import unittest
import sys
from distutils.core import setup, Extension, Command
from distutils.command.build_ext import build_ext
from subprocess import check_call


class RunTests(Command):
    """New setup.py command to run all tests for the package.
    """
    description = "run all tests for the package"

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        tests = unittest.TestLoader().discover('.')
        runner = unittest.TextTestRunner()
        results = runner.run(tests)
        sys.exit(not results.wasSuccessful())


class Build_WLP_ext(build_ext):
    def run(self):
        self.make_file(
            'wlp/commands.y', 'wlp/commands.tab.c', check_call,
            # Yes, the following line contains list-in-list-in-tuple, and
            # that's how it should be.
            # otherwise, subsequent calls down the stack unwind the list and
            # check_call won't get it.
            ([['yacc', '-d', '-o', 'wlp/commands.tab.c', 'wlp/commands.y']]),
            'Generating lexer')
        self.make_file(
            'wlp/commands.l', 'wlp/lex.yy.c', check_call,
            ([['lex', '-o', 'wlp/lex.yy.c', 'wlp/commands.l']]),
            'Generating parser')
        build_ext.run(self)

# see https://github.com/Turbo87/py-xcsoar/blob/master/setup.py
wlp_module = Extension('wlp',
                       sources=['wlp/wlp.c',
                                'wlp/structs.c',
                                'wlp/commands.tab.c',
                                'wlp/lex.yy.c'])

setup(name='pyg',
      version='0.9.9',  # the current Debian version is 0.9.8
      author="Cosimo Alfarano",
      author_email="kalfa@debian.org",  # FIXME I am an contributor?
      description='Python Mail <-> News Gateway',
      long_description='''
 Python Gateway Script from news to mail and vice versa.

 It is intended to be a full SMTP/NNTP rfc compliant gateway
 with whitelist manager.

 You will probably have to install a mail-transport-agent and/or
 news-transport-system package to manage SMTP/NNTP traffic.

 MTA is needed for mail2news service, since mail have to be
 processed on a box where pyg is installed. You can use a remote
 smtpserver for news2mail.

 News system is useful but not needed, since you can send articles to a
 remote SMTP server (ie: moderated NG) where is installed pyg, otherwise you
 will need it.

 It refers to rfc 822 (mail) and 850 (news).
      ''',
      py_modules=['mail2news', 'news2mail', 'pyginfo', 'setup', 'whitelist'],
      ext_modules=[wlp_module],
      scripts=['pygm2n', 'pygn2m'],
      cmdclass={'build_ext': Build_WLP_ext,
                'test': RunTests},
      # TODO package actually requires lex and yacc port, but not sure
      # how to say it here
      requires=[],
      license="GPLv2",
      keywords=["nntp", "email", "gateway"],
      classifiers=[
          'Development Status :: 3 - Alpha',
          'Programming Language :: Python :: 2.7',
          'Natural Language :: English',
          'Topic :: Office/Business :: Financial :: Accounting',
          'Topic :: Utilities',
          'Environment :: Console',
          'Operating System :: OS Independent',
          'License :: OSI Approved :: GNU Affero General Public License v3'
      ]
      )