forked from tohojo/flent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
87 lines (76 loc) · 3.17 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
## -*- coding: utf-8 -*-
##
## setup.py
##
## Author: Toke Høiland-Jørgensen ([email protected])
## Date: 4 december 2012
## Copyright (c) 2012, Toke Høiland-Jørgensen
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, os
from distutils.core import setup
from distutils.command.build_py import build_py as _build_py
from netperf_wrapper.build_info import VERSION
from glob import glob
version_string = VERSION
if sys.version_info[:2] < (2,6):
sys.stderr.write("Sorry, netperf-wrapper requires v2.6 or later of Python\n")
sys.exit(1)
class build_py(_build_py):
"""build_py command
This specific build_py command will modify module
'netperf_wrapper.build_config' so that it contains information on
installation prefixes afterwards.
"""
def build_module (self, module, module_file, package):
orig_content = None
if ( module == 'build_info' and package == 'netperf_wrapper'
and 'install' in self.distribution.command_obj):
iobj = self.distribution.command_obj['install']
with open(module_file, 'r') as module_fp:
orig_content = module_fp.read()
with open(module_file, 'w') as module_fp:
module_fp.write('# -*- coding: UTF-8 -*-\n\n')
module_fp.write("VERSION='%s'\n"%(version_string))
module_fp.write("DATA_DIR='%s'\n"%(
os.path.join(iobj.install_data, 'share', 'netperf-wrapper')))
_build_py.build_module(self, module, module_file, package)
if orig_content is not None:
with open(module_file, 'w') as module_fp:
module_fp.write(orig_content)
data_files = [('share/netperf-wrapper/tests',
glob("tests/*.conf") + \
glob("tests/*.inc")),
('share/doc/netperf-wrapper',
['BUGS',
'CHANGES',
'README.rst']),
('share/doc/netperf-wrapper/misc',
glob("misc/*.patch"))]
with open("README.rst") as fp:
long_description = "\n"+fp.read()
setup(name="netperf-wrapper",
version=version_string,
description="Wrapper for running network tests such as netperf concurrently",
long_description=long_description,
author="Toke Høiland-Jørgensen <[email protected]>",
author_email="[email protected]",
url="https://github.com/tohojo/netperf-wrapper",
license = "GNU GPLv3",
platforms = ['Linux'],
packages = ["netperf_wrapper"],
scripts = ["netperf-wrapper"],
data_files = data_files,
cmdclass = {'build_py': build_py},
)