initial package for geniwrapper.
[sfa.git] / setup.py
1 #!/usr/bin/python
2
3 """
4 Installation script for the geniwrapper module
5 """
6
7 from distutils.core import setup, Extension
8 import os, sys
9 import shutil
10
11 version = '0.2'
12 scripts = ['geni/gimport.py', 'geni/plc.py', 'cmdline/sfi.py', 'geni-config-tty']
13 package_dirs = ['geni', 'geni/util', 'geni/methods']
14 data_files = [('/etc/geni/', ['geni/aggregates.xml', 'geni/registries.xml', 'geni/util/geni_config', 'cmdline/configSfi.sh']),
15               ('/etc/init.d/', ['geni/geniwrapper'])]
16 symlinks = ['/usr/share/geniwrapper']
17 initscripts = ['/etc/init.d/geniwrapper']
18         
19 if sys.argv[1] in ['uninstall', 'remove', 'delete']:
20     python_path = sys.path
21     site_packages_only = lambda path: path.endswith('site-packages') 
22     site_packages_path = filter(site_packages_only, python_path)
23     add_geni_path = lambda path: path + os.sep + 'geni'
24     site_packages_path = map(add_geni_path, site_packages_path) 
25     remove_dirs = ['/etc/geni/'] + site_packages_path
26     remove_files = ['/usr/bin/gimport.py', '/usr/bin/plc.py', '/usr/bin/sfi.py'] + \
27                     symlinks + initscripts
28     
29     # remove files   
30     for filepath in remove_files:
31         print "removing", filepath, "...",
32         try: 
33             os.remove(filepath)
34             print "success"
35         except: print "failed"
36     # remove directories 
37     for directory in remove_dirs: 
38         print "removing", directory, "...",
39         try: 
40             shutil.rmtree(directory)
41             print "success"
42         except: print "failed"
43  
44 else:
45     setup(name='geniwrapper', 
46       version = version,
47       packages = package_dirs, 
48       data_files = data_files,
49       ext_modules = [],
50       py_modules = [],
51       scripts = scripts,   
52       url = 'http://svn.planet-lab.org/svn/geniwrapper/',
53       description = "Geni API",      
54       long_description = """\
55 Geniwrapper implements the Geni interface which serves 
56 as a layer between the existing PlanetLab interfaces 
57 and the Geni API.
58                     """,
59       license = 'GPL')
60
61     # create symlink to geniwrapper source in /usr/share
62     python_path = sys.path
63     site_packages_only = lambda path: path.endswith('site-packages')
64     site_packages_path = filter(site_packages_only, python_path)
65     add_geni_path = lambda path: path + os.sep + 'geni'
66     site_packages_path = map(add_geni_path, site_packages_path)
67     # python path usualy has /urs/local/lib/ path , filter this out
68     site_packages_path = filter(lambda x: 'local' not in x, site_packages_path) 
69
70     # we can not do this here as installation root might change paths
71     # - baris
72     #
73     # for src in site_packages_path:
74     #     for dst in symlinks:
75     #         try: 
76     #             os.symlink(src, dst)
77     #         except: pass
78     # for initscript in initscripts:
79     #     os.chmod(initscript, 00744)