1
|
|
|
"""Setup script. |
2
|
|
|
|
3
|
|
|
Run "python3 setup --help-commands" to list all available commands and their |
4
|
|
|
descriptions. |
5
|
|
|
""" |
6
|
|
|
import sys |
7
|
|
|
from abc import abstractmethod |
8
|
|
|
from subprocess import CalledProcessError, call, check_call |
9
|
|
|
|
10
|
|
|
from setuptools import Command, find_packages, setup |
11
|
|
|
from setuptools.command.test import test as TestCommand |
12
|
|
|
|
13
|
|
|
from pyof import __version__ |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
class SimpleCommand(Command): |
17
|
|
|
"""Make Command implementation simpler.""" |
18
|
|
|
|
19
|
|
|
user_options = [] |
20
|
|
|
|
21
|
|
|
@abstractmethod |
22
|
|
|
def run(self): |
23
|
|
|
"""Run when command is invoked. |
24
|
|
|
|
25
|
|
|
Use *call* instead of *check_call* to ignore failures. |
26
|
|
|
""" |
27
|
|
|
pass |
28
|
|
|
|
29
|
|
|
def initialize_options(self): |
30
|
|
|
"""Set defa ult values for options.""" |
31
|
|
|
pass |
32
|
|
|
|
33
|
|
|
def finalize_options(self): |
34
|
|
|
"""Post-process options.""" |
35
|
|
|
pass |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
class Linter(SimpleCommand): |
39
|
|
|
"""Code linters.""" |
40
|
|
|
|
41
|
|
|
description = 'run Pylama on Python files' |
42
|
|
|
|
43
|
|
|
def run(self): |
44
|
|
|
"""Run linter.""" |
45
|
|
|
self.lint() |
46
|
|
|
|
47
|
|
|
@staticmethod |
48
|
|
|
def lint(): |
49
|
|
|
"""Run pylama and radon.""" |
50
|
|
|
files = 'tests setup.py pyof' |
51
|
|
|
print('Pylama is running. It may take several seconds...') |
52
|
|
|
cmd = 'pylama {}'.format(files) |
53
|
|
|
try: |
54
|
|
|
check_call(cmd, shell=True) |
55
|
|
|
except CalledProcessError as e: |
56
|
|
|
print('FAILED: please, fix the error(s) above.') |
57
|
|
|
sys.exit(e.returncode) |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
class Cleaner(SimpleCommand): |
61
|
|
|
"""Custom clean command to tidy up the project root.""" |
62
|
|
|
|
63
|
|
|
description = 'clean build, dist, pyc and egg from package and docs' |
64
|
|
|
|
65
|
|
|
def run(self): |
66
|
|
|
"""Clean build, dist, pyc and egg from package and docs.""" |
67
|
|
|
call('rm -vrf ./build ./dist ./*.pyc ./*.egg-info', shell=True) |
68
|
|
|
call('cd docs; make clean', shell=True) |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
class Test(TestCommand): |
72
|
|
|
"""Run doctest and linter besides tests/*.""" |
73
|
|
|
|
74
|
|
|
def run(self): |
75
|
|
|
"""First, tests/*.""" |
76
|
|
|
super().run() |
77
|
|
|
print('Running examples in documentation') |
78
|
|
|
check_call('make doctest -C docs/', shell=True) |
79
|
|
|
Linter.lint() |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
requirements = [i.strip() for i in open("requirements.txt").readlines()] |
83
|
|
|
|
84
|
|
|
setup(name='python-openflow', |
85
|
|
|
version=__version__, |
86
|
|
|
description='Library to parse and generate OpenFlow messages', |
87
|
|
|
url='http://github.com/kytos/python-openflow', |
88
|
|
|
author='Kytos Team', |
89
|
|
|
author_email='[email protected]', |
90
|
|
|
license='MIT', |
91
|
|
|
test_suite='tests', |
92
|
|
|
install_requires=requirements, |
93
|
|
|
packages=find_packages(exclude=['tests', '*v0x02*']), |
94
|
|
|
cmdclass={ |
95
|
|
|
'lint': Linter, |
96
|
|
|
'clean': Cleaner, |
97
|
|
|
'test': Test |
98
|
|
|
}, |
99
|
|
|
zip_safe=False) |
100
|
|
|
|