forked from dropbox/nsot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·115 lines (90 loc) · 3.12 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
#!/usr/bin/env python
from distutils import log
from distutils.core import Command
import os
from subprocess import check_output
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from setuptools.command.develop import develop as DevelopCommand
from setuptools.command.sdist import sdist as SDistCommand
ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__)))
execfile('nsot/version.py')
with open('requirements.txt') as requirements:
required = requirements.read().splitlines()
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []
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
log.info('Running python tests...')
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
class DevelopWithBuildStatic(DevelopCommand):
def install_for_development(self):
self.run_command('build_static')
return DevelopCommand.install_for_development(self)
class SDistWithBuildStatic(SDistCommand):
def run(self):
self.run_command('build_static')
SDistCommand.run(self)
class BuildStatic(Command):
user_options = []
description = 'builds all front end dependencies'
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
log.info('running [npm install --quiet]')
check_output(['npm', 'install', '--quiet'], cwd=ROOT)
log.info('running [gulp clean]')
check_output(
[os.path.join(ROOT, 'node_modules', '.bin', 'gulp'), 'clean'],
cwd=ROOT
)
log.info('running [gulp build]')
check_output(
[os.path.join(ROOT, 'node_modules', '.bin', 'gulp'), 'build'],
cwd=ROOT
)
kwargs = {
'name': 'nsot',
'version': str(__version__), # noqa
'packages': find_packages(exclude=['tests*']),
'include_package_data': True,
'description': 'Network Source of Truth (IP Address Management).',
'author': 'Gary M. Josack',
'maintainer': 'Gary M. Josack',
'author_email': '[email protected]',
'maintainer_email': '[email protected]',
'license': 'Apache',
'install_requires': required,
'url': 'https://github.com/dropbox/nsot',
'tests_require': ['pytest'],
'cmdclass': {
'test': PyTest,
'build_static': BuildStatic,
'develop': DevelopWithBuildStatic,
'sdist': SDistWithBuildStatic,
},
'entry_points': """
[console_scripts]
nsot-server=nsot.util:main
snot-server=nsot.util:main
""",
'classifiers': [
'Programming Language :: Python',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
]
}
setup(**kwargs)