/
setup.py
executable file
·114 lines (96 loc) · 3.77 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
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python
from __future__ import with_statement
from distutils.core import setup, Command
from epydoc.docbuilder import build_doc_index
from epydoc.docwriter.html import HTMLWriter
class debian_substvars(Command):
description = 'Print distutils metadata in deb-substvars(5) format.'
user_options = [('file=', None, 'The substvars file to append to' ), ]
def initialize_options(self):
self.file = None
def finalize_options(self):
if self.file is None:
raise 'Must give the file option'
@classmethod
def fixup_description(cls, s):
lines = s.splitlines()
r = lines[0] + '${Newline}'
for l in lines[1:-1]:
r += '${Space}' + l + '${Newline}'
if len(lines) > 1:
r += '${Space}' + lines[-1]
return r
def run(self):
m = self.distribution.metadata
with open(self.file, 'a') as f:
f.write('distutils:Name=%s\n' % \
m.get_name())
f.write('distutils:Description=%s\n' % \
m.get_description())
f.write('distutils:Long-Description=%s\n' % \
self.fixup_description(m.get_long_description()))
class build_apidocs(Command):
description = 'Build the API reference using epydoc'
user_options = [('target-dir=', None, 'target directory for api docs')]
def initialize_options(self):
self.target_dir = 'apidocs'
def finalize_options(self):
pass
def find_items(self):
"""
Returns a list of package dirnames and module filenames
for which we should build docs.
This matches what the build_py command uses.
"""
# A less deeply integrated solution might be to use
# the build/ directory.
items = []
build_py = self.distribution.get_command_obj('build_py')
build_py.ensure_finalized()
if build_py.packages:
for package in build_py.packages:
package_dir = build_py.get_package_dir(package)
items.append(package_dir)
if build_py.py_modules:
for (package, module, module_file) in build_py.find_modules():
items.append(module_file)
return items
def run(self):
m = self.distribution.metadata
docindex = build_doc_index(self.find_items())
html_writer = HTMLWriter(
docindex,
prj_name=m.get_name(),
prj_url=m.get_url())
html_writer.write(self.target_dir)
setup(name='Systems',
version='0.1',
author='Gabriel de Perthuis',
author_email='g2p.code@gmail.com',
description='a declarative language for managing system resources',
license='http://www.gnu.org/licenses/gpl-2.0.html',
long_description='Systems allows you to write a declarative description\n'
+'of the resources that make up a system,\n'
+'and enforce this description.\n',
requires=['networkx', 'jinja2', 'epydoc', 'yaml', 'pygraphviz', ],
packages=[
'systems',
'systems.plugins',
'systems.plugins.apache2',
'systems.plugins.base',
'systems.plugins.duplicity',
'systems.plugins.files',
'systems.plugins.gnupg',
'systems.plugins.packages',
'systems.plugins.postgresql',
'systems.plugins.rails',
'systems.plugins.runit',
'systems.plugins.subversion',
'systems.util',
],
package_dir={'': 'lib'},
cmdclass={
'debian_substvars': debian_substvars,
'build_apidocs': build_apidocs,
},
)