added 2 new methods, 'get_aggregates' and 'get_registries'
[sfa.git] / setup.py
1 #!/usr/bin/python
2
3 """
4 Installation script for the geniwrapper module
5 """
6
7 import sys, os, os.path
8 import shutil
9 from distutils.core import setup
10
11 bins = [ 'config/sfa-config-tty',
12             'sfa/plc/sfa-import-plc.py', 
13             'sfa/plc/sfa-nuke-plc.py', 
14             'sfa/server/sfa-server.py', 
15             'sfa/client/sfi.py', 
16             'sfa/client/getNodes.py',
17             'sfa/client/getRecord.py',
18             'sfa/client/setRecord.py',
19             'sfa/client/genidump.py',
20             ]
21 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in bins ]
22
23 package_dirs = [ 'sfa', 
24                  'sfa/client',
25                  'sfa/methods',
26                  'sfa/plc',
27                  'sfa/server',
28                  'sfa/trust',
29                  'sfa/util', 
30                  'sfa/rspecs',
31                  'sfa/rspecs/aggregates'
32                  ]
33 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml', 
34                                'config/registries.xml', 
35                                'config/sfa_config', 
36                                'config/sfi_config',
37                                ]),
38                ('/etc/init.d/', ['sfa/init.d/sfa']),
39                ]
40 initscripts = [ '/etc/init.d/sfa' ]
41         
42 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
43     python_path = sys.path
44     site_packages_path = [ path + os.sep + 'sfa' for path in python_path if path.endswith('site-packages')]
45     remove_dirs = ['/etc/sfa/'] + site_packages_path
46     remove_files = remove_bins + initscripts
47     
48     # remove files   
49     for filepath in remove_files:
50         print "removing", filepath, "...",
51         try: 
52             os.remove(filepath)
53             print "success"
54         except: print "failed"
55     # remove directories 
56     for directory in remove_dirs: 
57         print "removing", directory, "...",
58         try: 
59             shutil.rmtree(directory)
60             print "success"
61         except: print "failed"
62  
63 else:
64     
65     # avoid repeating what's in the specfile already
66     setup(name='sfa',
67           packages = package_dirs, 
68           data_files = data_files,
69           ext_modules = [],
70           py_modules = [],
71           scripts = bins,   
72           )
73