forked from raiden-network/raiden-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
112 lines (93 loc) · 3.03 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
#!/usr/bin/env python3
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
import os
import sys
import distutils
from setuptools import Command
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist
DESCRIPTION = 'Raiden contracts library and utilities'
VERSION = '0.0.1'
COMPILED_CONTRACTS = 'raiden_contracts/data/contracts.json'
def read_requirements(path: str):
assert os.path.isfile(path)
with open(path) as requirements:
return requirements.read().split()
class BuildPyCommand(build_py):
def run(self):
try:
self.run_command('compile_contracts')
except SystemExit:
pass
build_py.run(self)
class SdistCommand(sdist):
def run(self):
if os.path.isfile(COMPILED_CONTRACTS) is False:
try:
self.run_command('build')
except SystemExit:
pass
super().run()
class CompileContracts(Command):
description = 'compile contracts to json'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# this is a rather ugly hack: populus doesn't allow setting of the output
# directory from the command line
# so we do following:
# 1) set proper argv for populus
# 2) set BUILD_ASSET_DIR that resides inside the Populus module to our custom dir
# 3) invoke populus main
#
old_argv = sys.argv
sys.argv = ['populus', 'compile']
try:
import populus.utils.compile
except ImportError:
self.announce(
'Populus not found. Skipping contract compilation',
level=distutils.log.WARN
)
return
populus.utils.compile.BUILD_ASSET_DIR = os.path.dirname(COMPILED_CONTRACTS)
from populus.cli import main
main()
sys.argv = old_argv
config = {
'version': VERSION,
'scripts': [],
'name': 'raiden-contracts',
'author': 'Brainbot Labs Est.',
'author_email': '[email protected]',
'description': DESCRIPTION,
'url': 'https://github.com/raiden-network/raiden-contracts/',
'license': 'MIT',
'keywords': 'raiden ethereum blockchain',
'install_requires': read_requirements('requirements.txt'),
'packages': find_packages(exclude=['*.tests*', 'contracts*']),
'include_package_data': True,
'classifiers': [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
],
'entry_points': {
'console_scripts': ['deploy = raiden_contracts.deploy.__main__:main'],
},
'cmdclass': {
'compile_contracts': CompileContracts,
'build_py': BuildPyCommand,
'sdist': SdistCommand
}
}
setup(**config)