an attempt to fix packaging with a fonts/ hierarchy
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 24 Jun 2014 08:35:44 +0000 (10:35 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 24 Jun 2014 08:35:44 +0000 (10:35 +0200)
setup.py

index 07e121b..a63e0cc 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,6 @@ from distutils.core import setup
 
 # we don't have a final list so let's keep it simple for now
 packages= [ os.path.dirname(init) for init in (glob("*/__init__.py")+glob("*/*/__init__.py")) ]
-print packages
 
 # Avoid troubles : clean /usr/share/unfold/
 #shutil.rmtree('/usr/share/unfold/')
@@ -24,6 +23,24 @@ def javascript (dir):
 def stylesheets (dir):
     return glob( dir+"/*.css")
 
+# looks like data_files requires actual files and cannot cope with 
+# a whole subdir like we have for fonts
+# returns a list of tuples suitable to add to data_files
+from operator import add
+
+def scan_fonts (install_topdir, topdir, extensions):
+    def subdir_tuples (subdir, extensions):
+        return [ (install_topdir+subdir, glob (subdir+"/*.%s"%extension), ) 
+                 for extension in extensions 
+                 if glob(subdir+"/*.%s"%extension)
+             ]
+    def subdirs (topdir):
+        return [x[0] for x in os.walk(topdir)]
+    return reduce (add, [ subdir_tuples (subdir, extensions) for subdir in subdirs(topdir) ] )
+
+fonts_tuples = scan_fonts ('/usr/share/unfold/static/fonts', 
+                           'static/fonts',
+                           ('otf','eot','svg','ttf','woff'))
 
 setup(packages = packages,
       # xxx somehow this does not seem to show up in debian packaging
@@ -35,9 +52,8 @@ setup(packages = packages,
 # for portal/          
           ( '/usr/share/unfold/static/img/institutions', images ('static/img/institutions')),
           ( '/usr/share/unfold/static/img/testbeds', images ('static/img/testbeds')),
-          ( '/usr/share/unfold/static/fonts', glob ('static/fonts/*')),
           ( '/usr/share/unfold/templates', glob ('templates/*')),
           ( 'apache', [ 'apache/unfold.conf', 'apache/unfold-ssl.conf', 'apache/unfold.wsgi' ]),
           ( '/etc/unfold/trusted_roots', []),
           ( '/var/unfold', []),
-        ])
+        ] + fonts_tuples )