forked from balanced/balanced-python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
133 lines (108 loc) · 3.49 KB
/
Copy pathsetup.py
File metadata and controls
133 lines (108 loc) · 3.49 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""
Balanced Python client library.
See ``README.mkd`` for usage advice.
"""
importos
importpickle
importre
importsubprocess
fromdistutils.coreimportCommand
try:
importsetuptools
exceptImportError:
importdistutils.core
setup=distutils.core.setup
else:
setup=setuptools.setup
classDocumentationCommand(Command):
description='build documentation and upload to s3'
path_to_pickled_file='docs/build/pickle/api_reference.fpickle'
destination_file='docs/build/python_api_reference.html'
user_options= []
definitialize_options(self):
pass
deffinalize_options(self):
pass
defrun(self):
self._build_docs()
self._upload_to_s3(self._unpickle(),
'justice.web',
'docs/python_api_reference.html')
def_build_docs(self):
p=subprocess.Popen('make clean'.split(), cwd='docs')
p.wait()
p=subprocess.Popen('make pickle'.split(), cwd='docs')
p.wait()
def_unpickle(self):
withopen(self.path_to_pickled_file) asf:
pickled=f.read()
unpickled=pickle.loads(pickled)
returnunpickled['body']
def_upload_to_s3(self, data, bucket, key_name):
fromboto.s3.connectionimportS3Connection
fromboto.s3.keyimportKey
conn=S3Connection()
bucket=conn.get_bucket(bucket)
key=Key(bucket)
key.key=key_name
key.set_contents_from_string(data)
key.set_acl('public-read')
def_get_version():
path=os.path.join(PATH_TO_FILE, 'balanced', '__init__.py')
version_re=r".*__version__ = '(.*?)'"
fo=open(path)
try:
returnre.compile(version_re, re.S).match(fo.read()).group(1)
finally:
fo.close()
def_get_long_description():
path=os.path.join(PATH_TO_FILE, 'README.mkd')
fo=open(path)
try:
returnfo.read()
finally:
fo.close()
defparse_requirements(file_name):
requirements= []
forlineinopen(file_name, 'r').read().split('\n'):
ifre.match(r'(\s*#)|(\s*$)', line):
continue
ifre.match(r'\s*-e\s+', line):
requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line))
elifre.match(r'\s*-f\s+', line):
pass
else:
requirements.append(line)
returnrequirements
defparse_dependency_links(file_name):
dependency_links= []
forlineinopen(file_name, 'r').read().split('\n'):
ifre.match(r'\s*-[ef]\s+', line):
dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line))
returndependency_links
PATH_TO_FILE=os.path.dirname(__file__)
VERSION=_get_version()
LONG_DESCRIPTION=_get_long_description()
setup(
name='balanced',
version=VERSION,
url='https://balancedpayments.com/',
license='BSD',
author='Mahmoud Abdelkader',
author_email='support@balancedpayments.com',
description='Payments platform for marketplaces',
long_description=LONG_DESCRIPTION,
packages=['balanced'],
test_suite='nose.collector',
install_requires=parse_requirements('requirements.txt'),
dependency_links=parse_dependency_links('requirements.txt'),
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
],
cmdclass={
'docs': DocumentationCommand,
}
)