forked from raiden-network/raiden-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
92 lines (75 loc) · 2.46 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
#!/usr/bin/env python3
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
import os
import json
from setuptools import Command
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist
from raiden_contracts.contract_manager import CONTRACT_MANAGER
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):
compiled = CONTRACT_MANAGER.precompile_contracts('contracts/', [])
with open(COMPILED_CONTRACTS, 'w') as compiled_json:
compiled_json.write(json.dumps(compiled))
config = {
'version': VERSION,
'scripts': [],
'name': 'raiden-contracts',
'author': 'Brainbot Labs Est.',
'author_email': 'contact@brainbot.li',
'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)