|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import os |
| 3 | +from setuptools import setup |
| 4 | + |
| 5 | +# |
| 6 | +# WIP: Not yet fully working / ready to be published on PyPI |
| 7 | +# |
| 8 | + |
| 9 | +DESC = """A slick sender rate limit policy daemon for Postfix implemented in Python3.""" |
| 10 | +with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme: |
| 11 | + README = readme.read() |
| 12 | +data_files = [] |
| 13 | + |
| 14 | + |
| 15 | +def add_data_file(dir, file, check_dir=False, mkdir=False): |
| 16 | + path = os.path.join(dir, os.path.basename(file)) |
| 17 | + if not os.path.isfile(path): |
| 18 | + if not check_dir or mkdir or os.path.isdir(dir): |
| 19 | + if mkdir: |
| 20 | + try: |
| 21 | + os.mkdir(dir) |
| 22 | + except OSError: |
| 23 | + pass |
| 24 | + data_files.append((dir, [file])) |
| 25 | + |
| 26 | +# if install as root populate /etc |
| 27 | +if os.getuid() == 0: |
| 28 | + add_data_file('/etc/logrotate.d', 'deployment/logrotate.d/policyd-rate-guard') |
| 29 | + add_data_file('/etc/systemd/system', 'deployment/systemd/policyd-rate-guard.service', check_dir=True) |
| 30 | + add_data_file('/etc/systemd/system', 'deployment/systemd/policyd-rate-guard-cleanup.service', check_dir=True) |
| 31 | + add_data_file('/etc/systemd/system', 'deployment/systemd/policyd-rate-guard-cleanup.timer', check_dir=True) |
| 32 | +# else use user .config dir |
| 33 | +#else: |
| 34 | +# conf_dir = os.path.expanduser("~/.config/") |
| 35 | +# add_data_file(conf_dir, 'policyd_rate_guard/policyd-rate-guard.yaml', mkdir=True) |
| 36 | + |
| 37 | + |
| 38 | +setup( |
| 39 | + name='policyd-rate-guard', |
| 40 | + version='0.5.0', |
| 41 | + description=DESC, |
| 42 | + long_description=README, |
| 43 | + author='Onlime GmbH', |
| 44 | + author_email='info@onlime.ch', |
| 45 | + license='GPLv3', |
| 46 | + url='https://github.com/nitmir/policyd-rate-limit', |
| 47 | + download_url="https://github.com/onlime/policyd-rate-guard/releases/latest", |
| 48 | + packages=['policyd_rate_guard', 'policyd_rate_guard.tests'], |
| 49 | + keywords=['Postfix', 'rate', 'limit', 'guard', 'email'], |
| 50 | + scripts=['run.py'], |
| 51 | + data_files=data_files, |
| 52 | + classifiers=[ |
| 53 | + 'Environment :: No Input/Output (Daemon)', |
| 54 | + 'Intended Audience :: Developers', |
| 55 | + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', |
| 56 | + 'Operating System :: POSIX', |
| 57 | + 'Programming Language :: Python', |
| 58 | + 'Programming Language :: Python :: 3', |
| 59 | + 'Topic :: Communications :: Email :: Mail Transport Agents', |
| 60 | + 'Topic :: Communications :: Email :: Filters', |
| 61 | + ], |
| 62 | + install_requires=["PyYAML >= 3.11"], |
| 63 | + zip_safe=False, |
| 64 | +) |
0 commit comments