forked from hyperledger-archives/sawtooth-arcade
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
90 lines (79 loc) · 3.05 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
# 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 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
setup(
name='sawtooth-arcade',
version=version('1.1.0'),
description='Example game implementations for Sawtooth Lake',
author='Intel Corporation',
url='http://www.intel.com',
packages=find_packages(),
install_requires=['sawtooth-core', 'colorlog', 'pybitcointools'],
entry_points={
'console_scripts': [
'xo = sawtooth_xo.xo_cli:main_wrapper'
]
})
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)