-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
101 lines (82 loc) · 2.48 KB
/
setup.py
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
# -*- coding: utf-8 -*-
#
# mete0r.mailer : mete0r's mailer
# Copyright (C) 2015 mete0r <mete0r@sarangbang.or.kr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import with_statement
from contextlib import contextmanager
import os.path
def setup_dir(f):
''' Decorate f to run inside the directory where setup.py resides.
'''
setup_dir = os.path.dirname(os.path.abspath(__file__))
def wrapped(*args, **kwargs):
with chdir(setup_dir):
return f(*args, **kwargs)
return wrapped
@contextmanager
def chdir(new_dir):
old_dir = os.path.abspath(os.curdir)
os.chdir(new_dir)
try:
yield
finally:
os.chdir(old_dir)
@setup_dir
def import_setuptools():
try:
import setuptools
return setuptools
except ImportError:
pass
import ez_setup
ez_setup.use_setuptools()
import setuptools
return setuptools
@setup_dir
def readfile(path):
with file(path) as f:
return f.read()
setup_info = {
'name': 'mete0r.mailer',
'version': readfile('VERSION.txt').strip(),
'description': 'mete0r\'s mailer',
'long_description': readfile('README.rst') + readfile('CHANGES.rst'),
'author': 'mete0r',
'author_email': 'mete0r@sarangbang.or.kr',
'license': 'GNU Affero General Public License v3 or later (AGPLv3+)',
# 'url': 'https://github.com/mete0r/mailer',
'packages': [
'mete0r_mailer'
],
'package_dir': {'': '.'},
'install_requires': [
'repoze.sendmail == 4.1',
'requests',
],
'entry_points': {
'console_scripts': [
'mete0r-mailer-qb = mete0r_mailer.cli:qb',
'mete0r-mailer-mail = mete0r_mailer.cli:mail',
],
}
}
@setup_dir
def main():
setuptools = import_setuptools()
setuptools.setup(**setup_info)
if __name__ == '__main__':
main()