builds two separate rpms : geniwrapper (server-side) and geniwrapper-sfi (client...
[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, Extension
10
11 scripts = [ 'geni/gimport.py', 
12             'geni/plc.py', 
13             'config/geni-config-tty',
14             'cmdline/sfi.py', 
15             'cmdline/getNodes.py',
16             'cmdline/getRecord.py',
17             'cmdline/setRecord.py',
18             'cmdline/genidump.py',
19             ]
20 package_dirs = ['geni', 'geni/util', 'geni/methods']
21 data_files = [ ('/etc/geni/', ['config/aggregates.xml', 'config/registries.xml', 
22                                'config/geni_config', 'config/sfi_config']),
23                ('/etc/init.d/', ['geni/init.d/geni'])]
24 symlinks = ['/usr/share/geniwrapper']
25 initscripts = ['/etc/init.d/geni']
26         
27 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
28     python_path = sys.path
29     site_packages_path = [ path + os.sep + 'geni' for path in python_path if path.endswith('site-packages')]
30     remove_dirs = ['/etc/geni/'] + site_packages_path
31     remove_files = ['/usr/bin/gimport.py', '/usr/bin/plc.py', '/usr/bin/sfi.py', '/usr/bin/geni-config-tty'] + \
32                     symlinks + initscripts
33     
34     # remove files   
35     for filepath in remove_files:
36         print "removing", filepath, "...",
37         try: 
38             os.remove(filepath)
39             print "success"
40         except: print "failed"
41     # remove directories 
42     for directory in remove_dirs: 
43         print "removing", directory, "...",
44         try: 
45             shutil.rmtree(directory)
46             print "success"
47         except: print "failed"
48  
49 else:
50     
51     # avoid repeating what's in the specfile already
52     setup(name='geni',
53           packages = package_dirs, 
54           data_files = data_files,
55           ext_modules = [],
56           py_modules = [],
57           scripts = scripts,   
58           )
59
60     # create symlink to geniwrapper source in /usr/share
61     python_path = sys.path
62     site_packages_path = [ path + os.sep + 'geni' for path in python_path if path.endswith('site-packages')]
63     # python path usualy has /usr/local/lib/ path , filter this out
64     site_packages_path = [x for x in site_packages_path if 'local' not in x]
65
66     # we can not do this here as installation root might change paths
67     # - baris
68     #
69     # for src in site_packages_path:
70     #     for dst in symlinks:
71     #         try: 
72     #             os.symlink(src, dst)
73     #         except: pass
74     # for initscript in initscripts:
75     #     os.chmod(initscript, 00744)