-
Notifications
You must be signed in to change notification settings - Fork 20
/
setup.py
executable file
·107 lines (95 loc) · 3.67 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
#!/usr/bin/env python
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2013,2014,2015,2017 Contributor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Basic setup.py for packaging Aquilon itself"""
import glob
import os
import shutil
import sys
from distutils.core import setup
from subprocess import Popen, PIPE
from distutils.command.install_scripts import install_scripts
from distutils.command.build import build
VERSIONFILE = "VERSION"
class BuildExcept(Exception):
pass
def get_version():
"""Returns a version for the package, based on git-describe, or in the
VERSION file."""
try:
with open(VERSIONFILE) as f:
return f.readline().strip()
except IOError:
with open(VERSIONFILE, "w") as f:
p = Popen("git describe".split(), stdout=f)
if p.wait() == 0:
return get_version()
else:
raise
def find_packages(path):
"""Finds all the Python packages under path"""
n = len(path)+1
l = []
for dirpath, dirnames, filenames in os.walk(path):
for d in dirnames:
base = dirpath[n:].replace(os.path.sep, ".")
base = base.strip()
if base:
m = '.'.join([base, d])
else:
m = d
l.append(m)
return l
def find_regular_files(path):
"""Finds all the regular files under a directory and returns the
tuples that would install such files"""
l = []
for dirpath, dirnames, filenames in os.walk(path):
base = dirpath.strip()
if base and filenames:
l.append(("/usr/share/aquilon/%s" % base,
[os.path.join(base, f) for f in filenames
if not f.endswith("py")]))
return l
all_packages = find_packages("lib")
all_packages.extend(find_packages("tools/bootstrap_ms"))
all_scripts = glob.glob(os.path.join("bin", "a*")) + \
glob.glob(os.path.join("sbin", "a*"))
all_scripts.extend(glob.glob(os.path.join("tools", "*.py")))
setup(name="aquilon",
version=get_version(),
description="Aquilon",
long_description="""Aquilon looks cool""",
license="Apache 2.0",
author="Quattor collaboration",
author_email="quattor-aquilon@lists.sourceforge.net",
package_dir={'aquilon' : 'lib/aquilon',
'twisted' : 'lib/twisted',
'ms': 'tools/bootstrap_ms/ms'},
packages=all_packages,
cmdclass = {"install_scripts" : install_scripts},
data_files=[("/usr/share/aquilon/etc",
glob.glob("etc/*.conf*") + glob.glob("etc/*xml")),
("/etc/init.d", ["etc/rc.d/init.d/aqd"]),
("/etc/sysconfig", ["etc/sysconfig/aqd"]),
("/etc/bash_completion.d", ["aq_bash_completion.sh"]),
("/usr/share/aquilon/mako/raw", glob.glob("etc/mako/raw/*")),
("/usr/share/aquilon/mako/pan", glob.glob("etc/mako/pan/*")),
("/usr/share/man/man1", glob.glob("doc/man/man1/*gz"))
] + find_regular_files("upgrade"),
scripts=all_scripts,
url="http://quattor.org")