-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
171 lines (126 loc) · 4.39 KB
/
setup.py
File metadata and controls
171 lines (126 loc) · 4.39 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from distutils.core import setup, Command
from distutils.sysconfig import get_python_lib
import datetime
import glob
import os
import sys
curdir = os.getcwd()
pylibdir = get_python_lib()
sys.path.append(curdir)
from pmaker.globals import PMAKER_AUTHOR, PMAKER_EMAIL, PMAKER_WEBSITE, \
PMAKER_TITLE as PACKAGE, PMAKER_VERSION as VERSION
# For daily snapshot versioning mode:
if os.environ.get("_SNAPSHOT_BUILD", None) is not None:
import datetime
VERSION = VERSION + datetime.datetime.now().strftime(".%Y%m%d")
def list_paths(path_pattern="*", topdir=curdir, pred=os.path.isfile):
return [p for p in glob.glob(os.path.join(topdir, path_pattern)) if pred(p)]
top_datadir = "share/pmaker"
def mk_tmpl_pair(tmpldir, top_datadir=top_datadir):
return (
os.path.join(top_datadir, tmpldir),
list_paths("%s/*" % tmpldir)
)
data_files = [
("share/man/man8", ["doc/pmaker.8", ]),
(os.path.join(pylibdir, "pmaker/tests"), list_paths("pmaker/tests/*_example_*")),
] + [
mk_tmpl_pair(d) for d in ("templates/1",
"templates/1/common",
"templates/1/common/debian",
"templates/1/common/debian/source",
"templates/1/autotools",
"templates/1/autotools/debian",
"templates/1/autotools.single",
"templates/1/buildrpm",
)
]
test_targets = \
glob.glob(os.path.join(curdir, "pmaker/tests/*.py")) + \
glob.glob(os.path.join(curdir, "pmaker/*/tests/*.py"))
test_targets_full = glob.glob(os.path.join(curdir, "tests/*.py"))
class TestCommand(Command):
user_options = [("full", "F",
"Fully test all including system/integration tests take much time to complete")]
boolean_options = ['full']
test_driver = os.path.join(curdir, "aux", "runtest.sh")
def initialize_options(self):
self.full = 0
def finalize_options(self):
if self.full and "FULL_TESTS" not in os.environ:
os.environ["FULL_TESTS"] = "1"
def run(self):
for f in test_targets:
os.system("PYTHONPATH=%s %s %s" % (curdir, self.test_driver, f))
if self.full:
for f in test_targets_full:
os.system("PYTHONPATH=%s %s %s" % (curdir, self.test_driver, f))
class SrpmCommand(Command):
user_options = []
build_stage = "s"
cmd_fmt = """rpmbuild -b%(build_stage)s \
--define \"_topdir %(rpmdir)s\" \
--define \"_sourcedir %(rpmdir)s\" \
--define \"_buildroot %(BUILDROOT)s\" \
%(rpmspec)s
"""
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.run_command('sdist')
self.build_rpm()
def build_rpm(self):
params = dict()
params["build_stage"] = self.build_stage
rpmdir = params["rpmdir"] = os.path.join(
os.path.abspath(os.curdir), "dist"
)
rpmspec = params["rpmspec"] = os.path.join(
rpmdir, "../%s.spec" % PACKAGE
)
for subdir in ("SRPMS", "RPMS", "BUILD", "BUILDROOT"):
sdir = params[subdir] = os.path.join(rpmdir, subdir)
if not os.path.exists(sdir):
os.makedirs(sdir, 0755)
c = open(rpmspec + ".in").read()
open(rpmspec, "w").write(c.replace("@VERSION@", VERSION))
os.system(self.cmd_fmt % params)
class RpmCommand(SrpmCommand):
build_stage = "b"
setup(name=PACKAGE,
version=VERSION,
description="A packaging helper tool",
author=PMAKER_AUTHOR,
author_email=PMAKER_EMAIL,
license="GPLv3+",
url=PMAKER_WEBSITE,
packages=[
"pmaker",
"pmaker.backend",
"pmaker.backend.autotools",
"pmaker.backend.autotools.single",
"pmaker.backend.autotools.single.tests",
"pmaker.backend.buildrpm",
"pmaker.backend.buildrpm.tests",
"pmaker.backend.tests",
"pmaker.collectors",
"pmaker.collectors.tests",
"pmaker.imported",
"pmaker.models",
"pmaker.models.tests",
"pmaker.tests",
],
scripts=[
"tools/pmaker",
"tools/pmaker"
],
data_files=data_files,
cmdclass={
"test": TestCommand,
"srpm": SrpmCommand,
"rpm": RpmCommand,
},
)
# vim:sw=4:ts=4:et: