-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
executable file
·79 lines (54 loc) · 1.91 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
from pprint import pprint
import sys, os, shutil
try:
from setuptools import setup, Command, find_packages
except ImportError as e:
print("Needs setuptools to install")
sys.exit(1)
try:
import yaml
except ImportError as e:
print("Needs pyyaml to install")
sys.exit(1)
# +-----------------------------------------------------------------------------
# | CONSTRUCT PARAMETERS FOR setuptools
# +-----------------------------------------------------------------------------
def trunc_lines(s):
parts = s.split('\n')
while len(parts[0]) == 0:
parts = parts[1:]
while len(parts[-1]) == 0:
parts = parts[:-1]
parts = [part for part in parts if len(part) > 0]
return ''.join(parts)
def build_keyword_dictionary(prefs):
keywords = {}
for key in [
'name', 'license', 'url', 'download_url', 'packages',
'package_dir', 'platforms', 'description', 'install_requires',
'long_description', 'package_data', 'include_package_data', 'scripts']:
if key in prefs:
keywords[key] = prefs[key]
keywords['author'] = \
', '.join(prefs['authors'][:-1]) + ' and ' + \
prefs['authors'][-1]
keywords['author_email'] = \
', '.join(prefs['emails'])
keywords["package_dir"] = \
{package: '/'.join(package.split('.')) for package in prefs['packages']}
keywords['long_description'] = \
trunc_lines(keywords['long_description'])
output = ""
first_tab = 40
second_tab = 60
for key in sorted(keywords.keys()):
value = keywords[key]
output += key.rjust(first_tab) + str(value).rjust(second_tab) + ""
return keywords
# load settings from setup.yaml
with open('setup.yaml') as f:
yaml_string = ''.join(f.readlines())
preferences = yaml.load(yaml_string)
setup_args = build_keyword_dictionary(preferences)
setup (**setup_args)
# TODO reintroduce versioneer