#!/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' ] )