forked from raiden-network/raiden
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·132 lines (108 loc) · 3.83 KB
/
setup.py
File metadata and controls
executable file
·132 lines (108 loc) · 3.83 KB
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
#!/usr/bin/env python
import os
import subprocess
from setuptools import setup, find_packages
from setuptools import Command
from setuptools.command.test import test as TestCommand
import distutils.log
from distutils.spawn import find_executable
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
raise SystemExit(errno)
class CompileWebUI(Command):
description = 'use npm to compile webui code to raiden/ui/web/dist'
user_options = [
('dev', 'D', 'use development preset, instead of production (default)'),
]
def initialize_options(self):
self.dev = None
def finalize_options(self):
pass
def run(self):
npm = find_executable('npm')
if not npm:
if os.environ.get('RAIDEN_NPM_MISSING_FATAL') is not None:
# Used in the automatic deployment scripts to prevent builds with missing web-ui
raise RuntimeError('NPM not found. Aborting')
self.announce('NPM not found. Skipping webUI compilation', level=distutils.log.WARN)
return
npm_run = 'build:prod'
if self.dev is not None:
npm_run = 'build:dev'
cwd = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'raiden',
'ui',
'web',
),
)
npm_version = subprocess.check_output([npm, '--version'])
# require npm 4.x.x or later
if not int(npm_version.split(b'.')[0]) >= 4:
self.announce(
'NPM 4.x or later required. Skipping webUI compilation',
level=distutils.log.WARN,
)
return
command = [npm, 'install']
self.announce('Running %r in %r' % (command, cwd), level=distutils.log.INFO)
subprocess.check_call(command, cwd=cwd)
command = [npm, 'run', npm_run]
self.announce('Running %r in %r' % (command, cwd), level=distutils.log.INFO)
subprocess.check_call(command, cwd=cwd)
self.announce('WebUI compiled with success!', level=distutils.log.INFO)
with open('README.rst') as readme_file:
readme = readme_file.read()
history = ''
install_requires_replacements = {
'git+https://github.com/LefterisJP/pystun@develop#egg=pystun': 'pystun',
}
install_requires = list(set(
install_requires_replacements.get(requirement.strip(), requirement.strip())
for requirement in open('requirements.txt') if not requirement.lstrip().startswith('#')
))
test_requirements = []
version = '0.6.0' # Do not edit: this is maintained by bumpversion (see .bumpversion_client.cfg)
setup(
name='raiden',
description='',
long_description=readme + '\n\n' + history,
author='Brainbot Labs Est.',
author_email='contact@brainbot.li',
url='https://github.com/raiden-network/raiden',
packages=find_packages(),
include_package_data=True,
license='MIT',
zip_safe=False,
keywords='raiden',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
],
cmdclass={
'test': PyTest,
'compile_webui': CompileWebUI,
},
use_scm_version=True,
setup_requires=['setuptools_scm'],
install_requires=install_requires,
tests_require=test_requirements,
python_requires='>=3.6',
entry_points={
'console_scripts': [
'raiden = raiden.__main__:main',
],
},
)