[Skencil-commits] r780 - skencil/branches/skencil-0.6

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Oct 31 01:43:43 CEST 2010


Author: igor_n
Date: 2010-10-31 01:43:36 +0200 (Sun, 31 Oct 2010)
New Revision: 780

Modified:
   skencil/branches/skencil-0.6/setup.py
Log:
messages dir processing fix for bdist_rpm, bdist_deb commands

Modified: skencil/branches/skencil-0.6/setup.py
===================================================================
--- skencil/branches/skencil-0.6/setup.py	2010-10-30 23:15:21 UTC (rev 779)
+++ skencil/branches/skencil-0.6/setup.py	2010-10-30 23:43:36 UTC (rev 780)
@@ -49,7 +49,7 @@
 
 #Return directory list for provided path
 def get_dirs(path='.'):
-    list=[]
+    list = []
     if path:
         if os.path.isdir(path):
             try:
@@ -64,8 +64,8 @@
             
 #Return full  directory names list for provided path    
 def get_dirs_withpath(path='.'):
-    list=[]
-    names=[]
+    list = []
+    names = []
     if os.path.isdir(path):
         try:
             names = os.listdir(path)
@@ -73,13 +73,13 @@
             return names
     names.sort()
     for name in names:
-        if os.path.isdir(os.path.join(path, name)) and not name=='.svn':
+        if os.path.isdir(os.path.join(path, name)) and not name == '.svn':
             list.append(os.path.join(path, name))
     return list
 
 #Return file list for provided path
 def get_files(path='.', ext='*'):    
-    list=[]
+    list = []
     if path:
         if os.path.isdir(path):
             try:
@@ -89,18 +89,18 @@
         names.sort()
         for name in names:
             if not os.path.isdir(os.path.join(path, name)):
-                if ext=='*':
+                if ext == '*':
                     list.append(name)
-                elif '.'+ext==name[-1*(len(ext)+1):]:
+                elif '.' + ext == name[-1 * (len(ext) + 1):]:
                     list.append(name)                
     return list
 
 #Return full file names list for provided path
 def get_files_withpath(path='.', ext='*'):
     import glob
-    list = glob.glob(os.path.join(path, "*."+ext))
+    list = glob.glob(os.path.join(path, "*." + ext))
     list.sort()
-    result=[]
+    result = []
     for file in list:
         if os.path.isfile(file):
             result.append(file)
@@ -108,37 +108,37 @@
 
 #Return recursive directories list for provided path
 def get_dirs_tree(path='.'):
-    tree=get_dirs_withpath(path)
-    res=[]+tree
+    tree = get_dirs_withpath(path)
+    res = [] + tree
     for node in tree:
-        subtree=get_dirs_tree(node)
-        res+=subtree
+        subtree = get_dirs_tree(node)
+        res += subtree
     return res    
     
 #Return recursive files list for provided path
 def get_files_tree(path='.', ext='*'):
-    tree=[]
-    dirs=[path,]    
-    dirs+=get_dirs_tree(path)
+    tree = []
+    dirs = [path, ]    
+    dirs += get_dirs_tree(path)
     for dir in dirs:
-        list = get_files_withpath(dir,ext)
+        list = get_files_withpath(dir, ext)
         list.sort()
-        tree+=list
+        tree += list
     return tree
  
 #Generates *.mo files Resources/Messages
 def generate_locales():
     print 'LOCALES BUILD'
-    files=get_files('po','po')
+    files = get_files('po', 'po')
     if len(files):
         for file in files:
-            lang=file.split('.')[0]    
-            po_file=os.path.join('po',file)        
-            mo_file=os.path.join('src','Resources','Messages',lang,'LC_MESSAGES','skencil.mo')
-            if not os.path.lexists(os.path.join('src','Resources','Messages',lang,'LC_MESSAGES')):
-                os.makedirs(os.path.join('src','Resources','Messages',lang,'LC_MESSAGES'))
-            print po_file, '==>',mo_file
-            os.system('msgfmt -o '+mo_file+' '+po_file)        
+            lang = file.split('.')[0]    
+            po_file = os.path.join('po', file)        
+            mo_file = os.path.join('src', 'Resources', 'Messages', lang, 'LC_MESSAGES', 'skencil.mo')
+            if not os.path.lexists(os.path.join('src', 'Resources', 'Messages', lang, 'LC_MESSAGES')):
+                os.makedirs(os.path.join('src', 'Resources', 'Messages', lang, 'LC_MESSAGES'))
+            print po_file, '==>', mo_file
+            os.system('msgfmt -o ' + mo_file + ' ' + po_file)        
 
 ############################################################
 #
@@ -148,26 +148,31 @@
 
 if __name__ == "__main__":
     
-    if len(sys.argv)>1 and sys.argv[1]=='build_locales':
+    if len(sys.argv) > 1 and sys.argv[1] == 'build_locales':
         generate_locales()
         sys.exit(0)
         
-    if len(sys.argv)>1 and sys.argv[1]=='build&copy':
-        COPY=True
-        sys.argv[1]='build'
+    if len(sys.argv) > 1 and sys.argv[1] == 'build&copy':
+        COPY = True
+        sys.argv[1] = 'build'
         generate_locales()
         
-    if len(sys.argv)>1 and sys.argv[1]=='bdist_deb':
-        DEBIAN=True
-        sys.argv[1]='build'
+    if len(sys.argv) > 1 and sys.argv[1] == 'bdist_deb':
+        DEBIAN = True
+        sys.argv[1] = 'build'
         generate_locales()        
         
-    if len(sys.argv)>1 and sys.argv[1]=='bdist_rpm':
+    if len(sys.argv) > 1 and sys.argv[1] == 'bdist_rpm':
         generate_locales()
         
-    if len(sys.argv)>1 and not sys.argv[1]=='sdist':    
+    if len(sys.argv) > 1 and not sys.argv[1] == 'sdist':    
         generate_locales()
         
+    dirs = get_dirs_tree('src/Resources/Messages')
+    messages_dirs = []
+    for item in dirs:
+        messages_dirs.append(os.path.join(item[4:], '*.*'))
+        
     
     from distutils.core import setup, Extension
 
@@ -189,80 +194,80 @@
                         ('MINOR_VERSION', '6')],
             sources=[intl_src + 'intl.c'])
     
-    type1mod_src=src_path+'extensions/Modules/'                
+    type1mod_src = src_path + 'extensions/Modules/'                
     type1mod_module = Extension('skencil.Sketch.Modules._type1module',
-            define_macros = [('MAJOR_VERSION', '0'),
+            define_macros=[('MAJOR_VERSION', '0'),
                         ('MINOR_VERSION', '6')],
-            sources = [type1mod_src+'_type1module.c'])
+            sources=[type1mod_src + '_type1module.c'])
     
-    skread_src=src_path+'extensions/Modules/'                
+    skread_src = src_path + 'extensions/Modules/'                
     skread_module = Extension('skencil.Sketch.Modules.skreadmodule',
-            define_macros = [('MAJOR_VERSION', '0'),
+            define_macros=[('MAJOR_VERSION', '0'),
                         ('MINOR_VERSION', '9')],
-            sources = [skread_src+'skreadmodule.c'])
+            sources=[skread_src + 'skreadmodule.c'])
     
-    pstokenize_src=src_path+'extensions/Modules/'                
+    pstokenize_src = src_path + 'extensions/Modules/'                
     pstokenize_module = Extension('skencil.Sketch.Modules.pstokenize',
-            define_macros = [('MAJOR_VERSION', '0'),
+            define_macros=[('MAJOR_VERSION', '0'),
                         ('MINOR_VERSION', '6')],
-            include_dirs=[filter_src],            
-            sources = [pstokenize_src+'pstokenize.c', pstokenize_src+'pschartab.c'])
+            include_dirs=[filter_src],
+            sources=[pstokenize_src + 'pstokenize.c', pstokenize_src + 'pschartab.c'])
 
 
     #Fix for Debian based distros
     tcl_include_dirs = []
-    tcl_ver=''
+    tcl_ver = ''
     if os.path.isdir('/usr/include/tcl8.5'):
         tcl_include_dirs = ['/usr/include/tcl8.5']
-        tcl_ver ='8.5'
+        tcl_ver = '8.5'
         
     if os.path.isdir('/usr/include/tcl8.6'):
         tcl_include_dirs = ['/usr/include/tcl8.6']
-        tcl_ver ='8.6'
+        tcl_ver = '8.6'
     
     #Fix for OpenSuse
     if not tcl_ver:
         if os.path.isfile('/usr/lib/libtcl8.5.so'):
-            tcl_ver ='8.5'
+            tcl_ver = '8.5'
         if os.path.isfile('/usr/lib/libtcl8.6.so'):
-            tcl_ver ='8.6'
+            tcl_ver = '8.6'
             
     if not tcl_ver:
         print 'System tcl/tk =>8.5 libraries have not found!'
         sys.exit(1)
     
     
-    paxtkinter_src=src_path+'extensions/Pax/'                
+    paxtkinter_src = src_path + 'extensions/Pax/'                
     paxtkinter_module = Extension('skencil.Sketch.Modules.paxtkinter',
-            define_macros = [('MAJOR_VERSION', '1'),
+            define_macros=[('MAJOR_VERSION', '1'),
                         ('MINOR_VERSION', '0')],
-            sources = [paxtkinter_src+'paxtkinter.c'],
-            include_dirs = tcl_include_dirs,
-            libraries=['tk'+tcl_ver, 'tcl'+tcl_ver])
+            sources=[paxtkinter_src + 'paxtkinter.c'],
+            include_dirs=tcl_include_dirs,
+            libraries=['tk' + tcl_ver, 'tcl' + tcl_ver])
     
     
-    pax_src=src_path+'extensions/Pax/'
+    pax_src = src_path + 'extensions/Pax/'
     pax_module = Extension('skencil.Sketch.Modules.paxmodule',
-            define_macros = [('MAJOR_VERSION', '0'),
+            define_macros=[('MAJOR_VERSION', '0'),
                         ('MINOR_VERSION', '6')],
-            sources = [pax_src+'borderobject.c', pax_src+'clipmask.c', pax_src+'cmapobject.c', 
-                    pax_src+'fontobject.c', pax_src+'gcobject.c',#  pax_src+'gcmethods.c',
-                    pax_src+'imageobject.c', pax_src+'intl.c', pax_src+'paxmodule.c', 
-                    pax_src+'paxutil.c', pax_src+'pixmapobject.c', pax_src+'regionobject.c', 
-                    pax_src+'tkwinobject.c'],
+            sources=[pax_src + 'borderobject.c', pax_src + 'clipmask.c', pax_src + 'cmapobject.c',
+                    pax_src + 'fontobject.c', pax_src + 'gcobject.c', #  pax_src+'gcmethods.c',
+                    pax_src + 'imageobject.c', pax_src + 'intl.c', pax_src + 'paxmodule.c',
+                    pax_src + 'paxutil.c', pax_src + 'pixmapobject.c', pax_src + 'regionobject.c',
+                    pax_src + 'tkwinobject.c'],
             include_dirs=tcl_include_dirs,
-            libraries=['X11', 'Xext', 'tk'+tcl_ver, 'tcl'+tcl_ver])
+            libraries=['X11', 'Xext', 'tk' + tcl_ver, 'tcl' + tcl_ver])
     
-    skmod_src=src_path+'extensions/Modules/'    
+    skmod_src = src_path + 'extensions/Modules/'    
     skmod_module = Extension('skencil.Sketch.Modules._sketchmodule',
-            define_macros = [('MAJOR_VERSION', '0'),
+            define_macros=[('MAJOR_VERSION', '0'),
                         ('MINOR_VERSION', '6')],
-            include_dirs=[src_path+'extensions/Pax/'],
-            sources = [skmod_src+'curvedraw.c', skmod_src+'curvefunc.c', skmod_src+'curvelow.c', 
-                    skmod_src+'curvemisc.c', skmod_src+'curveobject.c', skmod_src+'skaux.c', 
-                    skmod_src+'skcolor.c', skmod_src+'skdither.c', skmod_src+'_sketchmodule.c', 
-                    skmod_src+'skfm.c', skmod_src+'skimage.c', skmod_src+'skpoint.c', 
-                    skmod_src+'skrect.c', skmod_src+'sktrafo.c'],
+            include_dirs=[src_path + 'extensions/Pax/'],
+            sources=[skmod_src + 'curvedraw.c', skmod_src + 'curvefunc.c', skmod_src + 'curvelow.c',
+                    skmod_src + 'curvemisc.c', skmod_src + 'curveobject.c', skmod_src + 'skaux.c',
+                    skmod_src + 'skcolor.c', skmod_src + 'skdither.c', skmod_src + '_sketchmodule.c',
+                    skmod_src + 'skfm.c', skmod_src + 'skimage.c', skmod_src + 'skpoint.c',
+                    skmod_src + 'skrect.c', skmod_src + 'sktrafo.c'],
             libraries=['m', 'X11'])
     
     
@@ -325,14 +330,14 @@
                         'Resources/Misc/*.*',
                         'Resources/Misc/tkdefaults',
                         'Resources/Pixmaps/*.*',
-                        'Resources/Pixmaps/New12/*.*']
+                        'Resources/Pixmaps/New12/*.*'] + messages_dirs
             },
 
-            scripts=['src/skencil'],    
+            scripts=['src/skencil'],
                     
             data_files=[
-                    ('/usr/share/applications',['src/skencil.desktop',]),
-                    ('/usr/share/pixmaps',['src/skencil.png','src/skencil.xpm',]),
+                    ('/usr/share/applications', ['src/skencil.desktop', ]),
+                    ('/usr/share/pixmaps', ['src/skencil.png', 'src/skencil.xpm', ]),
                     ],
 
             ext_modules=[filter_module, intl_module, skread_module, type1mod_module,
@@ -341,7 +346,7 @@
 #################################################
 # .py source compiling
 #################################################
-if sys.argv[1]=='build':
+if sys.argv[1] == 'build':
     import compileall
     compileall.compile_dir('build/')
     
@@ -355,30 +360,30 @@
             
 if COPY:
     import string, platform
-    version=(string.split(sys.version)[0])[0:3]
+    version = (string.split(sys.version)[0])[0:3]
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/paxmodule.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/paxmodule.so', 'src/Sketch/Modules/')
     print '\n paxmodule.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/paxtkinter.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/paxtkinter.so', 'src/Sketch/Modules/')
     print '\n paxtkinter.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/intl.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/intl.so', 'src/Sketch/Modules/')
     print '\n intl.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/pstokenize.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/pstokenize.so', 'src/Sketch/Modules/')
     print '\n pstokenize.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/_sketchmodule.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/_sketchmodule.so', 'src/Sketch/Modules/')
     print '\n _sketchmodule.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/skreadmodule.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/skreadmodule.so', 'src/Sketch/Modules/')
     print '\n skreadmodule.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/streamfilter.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/streamfilter.so', 'src/Sketch/Modules/')
     print '\n streamfilter.so has been copied to src/ directory'
     
-    shutil.copy('build/lib.linux-'+platform.machine()+'-'+version+'/skencil/Sketch/Modules/_type1module.so','src/Sketch/Modules/')
+    shutil.copy('build/lib.linux-' + platform.machine() + '-' + version + '/skencil/Sketch/Modules/_type1module.so', 'src/Sketch/Modules/')
     print '\n _type1module.so has been copied to src/ directory'
     
     os.system('rm -rf build')
@@ -392,28 +397,28 @@
     print '\nDEBIAN PACKAGE BUILD'
     print '===================='
     import string, platform
-    version=(string.split(sys.version)[0])[0:3]
+    version = (string.split(sys.version)[0])[0:3]
     
-    arch,bin = platform.architecture()
-    if arch=='64bit':
-        arch='amd64'
+    arch, bin = platform.architecture()
+    if arch == '64bit':
+        arch = 'amd64'
     else:
-        arch='i386'
+        arch = 'i386'
         
-    target='build/deb-root/usr/lib/python'+version+'/dist-packages'
+    target = 'build/deb-root/usr/lib/python' + version + '/dist-packages'
     
-    if os.path.lexists(os.path.join('build','deb-root')):
+    if os.path.lexists(os.path.join('build', 'deb-root')):
         os.system('rm -rf build/deb-root')
-    os.makedirs(os.path.join('build','deb-root','DEBIAN'))
+    os.makedirs(os.path.join('build', 'deb-root', 'DEBIAN'))
     
-    os.system("cat DEBIAN/control |sed 's/<PLATFORM>/"+arch+"/g'|sed 's/<VERSION>/"+VERSION+"/g'> build/deb-root/DEBIAN/control")    
+    os.system("cat DEBIAN/control |sed 's/<PLATFORM>/" + arch + "/g'|sed 's/<VERSION>/" + VERSION + "/g'> build/deb-root/DEBIAN/control")    
 
     os.makedirs(target)
     os.makedirs('build/deb-root/usr/bin')
     os.makedirs('build/deb-root/usr/share/applications')
     os.makedirs('build/deb-root/usr/share/pixmaps')    
     
-    os.system('cp -R build/lib.linux-'+platform.machine()+'-'+version+'/skencil '+target)
+    os.system('cp -R build/lib.linux-' + platform.machine() + '-' + version + '/skencil ' + target)
     os.system('cp src/skencil.desktop build/deb-root/usr/share/applications')
     os.system('cp src/skencil.png build/deb-root/usr/share/pixmaps')    
     os.system('cp src/skencil.xpm build/deb-root/usr/share/pixmaps')
@@ -425,4 +430,4 @@
     else:
         os.makedirs('dist')
     
-    os.system('dpkg --build build/deb-root/ dist/python-skencil-'+VERSION+'_'+arch+'.deb')    
\ No newline at end of file
+    os.system('dpkg --build build/deb-root/ dist/python-skencil-' + VERSION + '_' + arch + '.deb')    



More information about the Skencil-commits mailing list