-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·197 lines (153 loc) · 5.11 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#! /usr/bin/env python
"""Setup file for ncdiff package
See:
https://packaging.python.org/en/latest/distributing.html
"""
import os
import re
import sys
import shlex
import unittest
import subprocess
from setuptools import setup, find_packages, Command
from setuptools.command.test import test
pkg_name = 'ncdiff'
pkg_path = '/'.join(pkg_name.split('.'))
class CleanCommand(Command):
'''Custom clean command
cleanup current directory:
- removes build/
- removes src/*.egg-info
- removes *.pyc and __pycache__ recursively
Example
-------
python setup.py clean
'''
user_options = []
description = 'CISCO SHARED : Clean all build artifacts'
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf ./build ./dist ./src/*.egg-info')
os.system('find . -type f -name "*.pyc" | xargs rm -vrf')
os.system('find . -type d -name "__pycache__" | xargs rm -vrf')
class TestCommand(Command):
user_options = []
description = 'CISCO SHARED : Run unit tests against this package'
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# where the tests are (relative to here)
tests = os.path.join('src', pkg_path, 'tests')
# call unittests
sys.exit(unittest.main(
module = None,
argv = ['python -m unittest', 'discover', tests],
failfast = True))
class BuildDocs(Command):
user_options = []
description = ('CISCO SHARED : Build and privately distribute '
'Sphinx documentation for this package')
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
user = os.environ['USER']
sphinx_build_cmd = "sphinx-build -b html -c docs/ " \
"-d ./__build__/documentation/doctrees docs/ ./__build__/documentation/html"
try:
ret_code = subprocess.call(shlex.split(sphinx_build_cmd))
sys.exit(0)
except Exception as e:
print("Failed to build documentation : {}".format(str(e)))
sys.exit(1)
def read(*paths):
'''read and return txt content of file'''
with open(os.path.join(os.path.dirname(__file__), *paths)) as fp:
return fp.read()
def find_version(*paths):
'''reads a file and returns the defined __version__ value'''
version_match = re.search(r"^__version__ ?= ?['\"]([^'\"]*)['\"]",
read(*paths), re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
# launch setup
setup(
name = pkg_name,
version = find_version('src', pkg_path, '__init__.py'),
# descriptions
description = 'A config state diff calculator for NETCONF',
long_description = 'A package to generate NETCONF edit-config when two config states are given.',
# the package's documentation page.
url = 'https://github.com/CiscoTestAutomation/ncdiff.git',
# author details
author = 'Jonathan Yang',
author_email = '[email protected]',
maintainer_email = '[email protected]',
# project licensing
license = 'Apache 2.0',
# see https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Telecommunications Industry',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Testing',
],
# project keywords
keywords = 'pyats cisco-shared',
# project packages
packages = find_packages(where = 'src'),
# project directory
package_dir = {
'': 'src',
},
# additional package data files that goes into the package itself
package_data = {'':['README.rst',
'tests/yang/*.*']},
# Standalone scripts
scripts = [
],
# console entry point
entry_points = {
},
# package dependencies
install_requires = [
'ncclient >= 0.5.3',
'pyang >= 1.7.3',
],
# any additional groups of dependencies.
# install using: $ pip install -e .[dev]
extras_require = {
'dev': ['coverage',
'restview',
'Sphinx',
'sphinxcontrib-napoleon',
'sphinx-rtd-theme'],
},
# any data files placed outside this package.
# See: http://docs.python.org/3.4/distutils/setupscript.html
# format:
# [('target', ['list', 'of', 'files'])]
# where target is sys.prefix/<target>
data_files = [],
# custom commands for setup.py
cmdclass = {
'clean': CleanCommand,
'test': TestCommand,
'docs': BuildDocs,
},
# non zip-safe (never tested it)
zip_safe = False,
)