renaming the toplevel geni/ package into sfa/
[sfa.git] / setup.py
1 #!/usr/bin/python
2
3 """
4 Installation script for the geniwrapper module
5 """
6
7 import os, sys
8 import shutil
9 from distutils.core import setup
10
11 scripts = [ 'config/sfa-config-tty',
12             'sfa/plc/sfa-import-plc.py', 
13             'sfa/server/sfa-server.py', 
14             'sfa/client/sfi.py', 
15             'sfa/client/getNodes.py',
16             'sfa/client/getRecord.py',
17             'sfa/client/setRecord.py',
18             'sfa/client/genidump.py',
19             ]
20 package_dirs = [ 'sfa', 
21                  'sfa/client',
22                  'sfa/methods',
23                  'sfa/plc',
24                  'sfa/server',
25                  'sfa/trust',
26                  'sfa/util', 
27                  ]
28 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml', 
29                                'config/registries.xml', 
30                                'config/sfa_config', 
31                                'config/sfi_config',
32                                ]),
33                ('/etc/init.d/', ['sfa/init.d/sfa']),
34                ('/var/www/html/wsdl', [ 'wsdl/sfa.wsdl' ] ),
35                ]
36 symlinks = [ '/usr/share/sfa' ]
37 initscripts = [ '/etc/init.d/sfa' ]
38         
39 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
40     python_path = sys.path
41     site_packages_path = [ path + os.sep + 'sfa' for path in python_path if path.endswith('site-packages')]
42     remove_dirs = ['/etc/sfa/'] + site_packages_path
43     remove_files = [ '/usr/bin/sfa-config-tty',
44                      '/usr/bin/sfa-import-plc.py', 
45                      '/usr/bin/sfa-server.py', 
46                      '/usr/bin/sfi.py', 
47                      '/usr/bin/getNodes.py',
48                      '/usr/bin/getRecord.py',
49                      '/usr/bin/setRecord.py',
50                      '/usr/bin/genidump.py',
51                     ] + symlinks + initscripts
52     
53     # remove files   
54     for filepath in remove_files:
55         print "removing", filepath, "...",
56         try: 
57             os.remove(filepath)
58             print "success"
59         except: print "failed"
60     # remove directories 
61     for directory in remove_dirs: 
62         print "removing", directory, "...",
63         try: 
64             shutil.rmtree(directory)
65             print "success"
66         except: print "failed"
67  
68 else:
69     
70     # avoid repeating what's in the specfile already
71     setup(name='sfa',
72           packages = package_dirs, 
73           data_files = data_files,
74           ext_modules = [],
75           py_modules = [],
76           scripts = scripts,   
77           )
78
79     # create symlink to geniwrapper source in /usr/share
80     python_path = sys.path
81     site_packages_path = [ path + os.sep + 'sfa' for path in python_path if path.endswith('site-packages')]
82     # python path usualy has /usr/local/lib/ path , filter this out
83     site_packages_path = [x for x in site_packages_path if 'local' not in x]
84
85     # we can not do this here as installation root might change paths
86     # - baris
87     #
88     # for src in site_packages_path:
89     #     for dst in symlinks:
90     #         try: 
91     #             os.symlink(src, dst)
92     #         except: pass
93     # for initscript in initscripts:
94     #     os.chmod(initscript, 00744)