This repository has been archived by the owner on Nov 30, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.py
137 lines (118 loc) · 4.93 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright 2016 Intel Corporation
#
# 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.
# ------------------------------------------------------------------------------
import os
import shutil
import subprocess
import sys
# from distutils.core import setup, Extension, find_packages
from setuptools import setup, find_packages
def bump_version(version):
(major, minor, patch) = version.split('.')
patch = str(int(patch) + 1)
return ".".join([major, minor, patch])
def auto_version(default, strict):
output = subprocess.check_output(['git', 'describe', '--dirty'])
parts = output.strip().split('-', 1)
parts[0] = parts[0][1:] # strip the leading 'v'
if len(parts) == 2:
parts[0] = bump_version(parts[0])
if default != parts[0]:
msg = "setup.py and (bumped?) git describe versions differ: " \
"{} != {}".format(default, parts[0])
if strict:
print >> sys.stderr, "ERROR: " + msg
sys.exit(1)
else:
print >> sys.stderr, "WARNING: " + msg
print >> sys.stderr, "WARNING: using setup.py version {}".format(
default)
parts[0] = default
if len(parts) == 2:
return "-git".join([parts[0], parts[1].replace("-", ".")])
else:
return parts[0]
def version(default):
if 'VERSION' in os.environ:
if os.environ['VERSION'] == 'AUTO_STRICT':
version = auto_version(default, strict=True)
elif os.environ['VERSION'] == 'AUTO':
version = auto_version(default, strict=False)
else:
version = os.environ['VERSION']
else:
version = default + "-dev1"
return version
if os.name == 'nt':
conf_dir = "C:\\Program Files (x86)\\Intel\\sawtooth-validator\\conf"
log_dir = "C:\\Program Files (x86)\\Intel\\sawtooth-validator\\logs"
data_dir = "C:\\Program Files (x86)\\Intel\\sawtooth-validator\\data"
run_dir = "C:\\Program Files (x86)\\Intel\\sawtooth-validator\\run"
static_content_dir = "Lib\\site-packages\\txnserver\\static_content"
else:
conf_dir = "/etc/sawtooth-validator"
log_dir = "/var/log/sawtooth-validator"
data_dir = "/var/lib/sawtooth-validator"
run_dir = "/var/run/sawtooth-validator"
static_content_dir = "lib/python2.7/dist-packages/txnserver/static_content"
# collect the static files to put in the installation dir
static_content_files = []
for root, dirs, files in os.walk("txnserver/static_content"):
for file in files:
static_content_files.append(os.path.join(root, file))
data_files = [
(conf_dir, ["etc/txnvalidator.js.example",
"etc/txnvalidator-logging.js.example",
"etc/txnvalidator-logging.yaml.example"]),
(os.path.join(conf_dir, "keys"), []),
(log_dir, []),
(data_dir, []),
(run_dir, []),
(static_content_dir, static_content_files),
]
if os.path.exists("/etc/debian_version"):
data_files.append(('/etc/init', ['etc/init/sawtooth-validator.conf']))
data_files.append(('/etc/default', ['etc/default/sawtooth-validator']))
if os.path.exists("/etc/SuSE-release"):
data_files.append(('/usr/lib/systemd/system',
['etc/systemd/sawtooth-validator.service']))
data_files.append(('/etc/sysconfig', ['etc/default/sawtooth-validator']))
setup(
name='sawtooth-validator',
version=version('1.1.1'),
description='Validator service for Sawtooth Lake distributed ledger from ',
author='Mic Bowman, Intel Labs',
url='http://www.intel.com',
packages=find_packages(),
install_requires=['sawtooth-core', 'cbor>=0.1.23', 'colorlog',
'twisted', 'PyYAML', 'psutil', 'numpy'],
data_files=data_files,
entry_points={
'console_scripts': [
'txnkeygen = txnmain.key_gen_cli:main',
'txnvalidator = txnmain.validator_cli:main_wrapper',
'txnadmin = txnmain.admin_cli:main'
]
})
if "clean" in sys.argv and "--all" in sys.argv:
directory = os.path.dirname(os.path.realpath(__file__))
for root, fn_dir, files in os.walk(directory):
for fn in files:
if fn.endswith(".pyc"):
os.remove(os.path.join(root, fn))
for filename in [".coverage"]:
if os.path.exists(os.path.join(directory, filename)):
os.remove(os.path.join(directory, filename))
shutil.rmtree(os.path.join(directory, "htmlcov"), ignore_errors=True)
shutil.rmtree(os.path.join(directory, "deb_dist"), ignore_errors=True)