1
1
"""setup.py file."""
2
+ import napalm
3
+
2
4
import uuid
3
5
6
+ from distutils .core import Command
4
7
from setuptools import setup , find_packages
8
+ from setuptools .command import install
9
+
10
+
5
11
from pip .req import parse_requirements
6
- from itertools import chain
7
12
13
+ import pip
8
14
import sys
9
15
10
- __author__ = 'David Barroso <[email protected] >'
11
16
17
+ __author__ = 'David Barroso <[email protected] >'
12
18
13
- def extract_drivers (opt ):
14
- return set ([r .replace ("--drivers=" , "" ).strip () for r in opt .split ("," )])
15
19
20
+ def process_requirements (dep ):
21
+ print ("PROCESSING DEPENDENCIES FOR {}" .format (dep ))
22
+ u = uuid .uuid1 ()
23
+ iter_reqs = parse_requirements ("requirements/{}" .format (dep ), session = u )
24
+ [pip .main (['install' , (str (ir .req ))]) for ir in iter_reqs ]
16
25
17
- def process_requirements ():
18
- develop = False
19
- if 'egg_info' in sys .argv :
20
- return []
21
- elif 'develop' in sys .argv :
22
- develop = True
23
26
24
- requirements = set ()
25
- for r in sys . argv :
26
- if r . startswith ( "--drivers" ):
27
- requirements |= extract_drivers ( r )
27
+ def custom_command_driver ( driver ):
28
+ class CustomCommand ( Command ) :
29
+ """A custom command to run Pylint on all Python source files."""
30
+ user_options = []
28
31
29
- # let's remove the options
30
- sys . argv = [ o for o in sys . argv if not o . startswith ( "--drivers" )]
32
+ def initialize_options ( self ):
33
+ pass
31
34
32
- requirements = requirements or set ([ 'all' ])
33
- requirements . add ( 'base' )
35
+ def finalize_options ( self ):
36
+ pass
34
37
35
- u = uuid .uuid1 ()
38
+ def run (self ):
39
+ """Run command."""
40
+ process_requirements (driver )
36
41
37
- iter_reqs = chain (* [parse_requirements ("requirements/{}" .format (r ), session = u )
38
- for r in requirements ])
42
+ return CustomCommand
39
43
40
- if develop :
41
- import pip
42
- [pip .main (['install' , (str (ir .req ))]) for ir in iter_reqs ]
43
44
44
- return [str (ir .req ) for ir in iter_reqs ]
45
+ class CustomInstall (install .install ):
46
+ """A custom command to run Pylint on all Python source files."""
45
47
48
+ def run (self ):
49
+ """Run command."""
50
+ if any ([d in sys .argv for d in napalm .SUPPORTED_DRIVERS ]):
51
+ process_requirements ('base' )
52
+ else :
53
+ process_requirements ('all' )
54
+ install .install .run (self )
46
55
47
- reqs = process_requirements ()
48
56
57
+ custom_commands = {d : custom_command_driver (d ) for d in napalm .SUPPORTED_DRIVERS }
58
+ custom_commands ['install' ] = CustomInstall
49
59
50
60
setup (
61
+ cmdclass = custom_commands ,
51
62
name = "napalm" ,
52
- version = '2.0.0a1 ' ,
63
+ version = '2.0.0a3 ' ,
53
64
packages = find_packages (exclude = ("test*" , )),
54
65
test_suite = 'test_base' ,
55
66
author = "David Barroso, Kirk Byers, Mircea Ulinic" ,
@@ -69,7 +80,7 @@ def process_requirements():
69
80
],
70
81
url = "https://github.com/napalm-automation/napalm" ,
71
82
include_package_data = True ,
72
- install_requires = reqs ,
83
+ install_requires = [] ,
73
84
entry_points = {
74
85
'console_scripts' : [
75
86
'cl_napalm_configure=napalm.base.clitools.cl_napalm_configure:main' ,
0 commit comments