forked from clalancette/oz
-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
71 lines (62 loc) · 2.37 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
from distutils.core import setup, Extension, Command
from distutils.command.sdist import sdist as _sdist
import os
import subprocess
import time
VERSION = '0.9.0'
RELEASE = '0'
datafiles = [('share/man/man1', ['man/oz-install.1', 'man/oz-customize.1',
'man/oz-generate-icicle.1',
'man/oz-cleanup-cache.1'])
]
class sdist(_sdist):
""" custom sdist command, to prep oz.spec file for inclusion """
def run(self):
global VERSION
global RELEASE
# Create a development release string for later use
git_head = subprocess.Popen("git log -1 --pretty=format:%h",
shell=True,
stdout=subprocess.PIPE).communicate()[0].strip()
date = time.strftime("%Y%m%d%H%M%S", time.gmtime())
git_release = "%sgit%s" % (date, git_head)
# Expand macros in oz.spec.in and create oz.spec
spec_in = open('oz.spec.in', 'r')
spec = open('oz.spec', 'w')
for line in spec_in.xreadlines():
if "@VERSION@" in line:
line = line.replace("@VERSION@", VERSION)
elif "@RELEASE@" in line:
# If development release, include date+githash in %{release}
if RELEASE.startswith('0'):
RELEASE += '.' + git_release
line = line.replace("@RELEASE@", RELEASE)
spec.write(line)
spec_in.close()
spec.close()
# Run parent constructor
_sdist.run(self)
class pytest(Command):
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
import subprocess
errno = subprocess.call('py.test tests --verbose --tb=short --junitxml=tests/results.xml'.split())
raise SystemExit(errno)
setup(name='oz',
version=VERSION,
description='Oz automated installer',
author='Chris Lalancette',
author_email='clalance@redhat.com',
license='LGPLv2',
url='http://aeolusproject.org/oz.html',
package_dir={'oz': 'oz'},
package_data={'oz': ['auto/*']},
packages=['oz'],
scripts=['oz-install', 'oz-generate-icicle', 'oz-customize',
'oz-cleanup-cache'],
cmdclass={'sdist': sdist,
'test' : pytest },
data_files = datafiles,
)