AiC and REST login
[myslice.git] / setup.py
1 #!/usr/bin/python
2 #
3 # Setup script for myslice+unfold
4 #
5 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
6 # INRIA (c) 2013
7
8 import os.path
9 import shutil
10 from glob import glob
11 from distutils.core import setup
12
13 # we don't have a final list so let's keep it simple for now
14 packages= [ os.path.dirname(init) for init in (glob("*/__init__.py")+glob("*/*/__init__.py")) ]
15
16 # Avoid troubles : clean /usr/share/unfold/
17 #shutil.rmtree('/usr/share/unfold/')
18
19 def images (dir):
20     return glob( dir+"/*.png") + glob ( dir+"/*.gif")
21 def javascript (dir):
22     return glob( dir+"/*.js")
23 def stylesheets (dir):
24     return glob( dir+"/*.css")
25
26 # looks like data_files requires actual files and cannot cope with 
27 # a whole subdir like we have for fonts
28 # returns a list of tuples suitable to add to data_files
29 from operator import add
30
31 def scan_fonts (install_topdir, topdir, extensions):
32     def subdir_tuples (subdir, extensions):
33         return [ (install_topdir+subdir, glob (subdir+"/*.%s"%extension), ) 
34                  for extension in extensions 
35                  if glob(subdir+"/*.%s"%extension)
36              ]
37     def subdirs (topdir):
38         return [x[0] for x in os.walk(topdir)]
39     return reduce (add, [ subdir_tuples (subdir, extensions) for subdir in subdirs(topdir) ] )
40
41 fonts_tuples = scan_fonts ('/usr/share/unfold/static/fonts', 
42                            'static/fonts',
43                            ('otf','eot','svg','ttf','woff'))
44
45 setup(packages = packages,
46       # xxx somehow this does not seem to show up in debian packaging
47       scripts = [ 'apache/unfold-init-ssl.sh' ],
48       data_files = [ 
49           ( '/usr/share/unfold/static/js', javascript('static/js')),
50           ( '/usr/share/unfold/static/css', stylesheets ('static/css')),
51           ( '/usr/share/unfold/static/img', images ('static/img')),
52 # for portal/          
53           ( '/usr/share/unfold/static/img/institutions', images ('static/img/institutions')),
54           ( '/usr/share/unfold/static/img/testbeds', images ('static/img/testbeds')),
55           ( '/usr/share/unfold/templates', glob ('templates/*')),
56           ( 'apache', [ 'apache/unfold.conf', 'apache/unfold-ssl.conf', 'apache/unfold.wsgi' ]),
57           ( '/etc/unfold/trusted_roots', []),
58           ( '/var/unfold', []),
59         ] + fonts_tuples )