windowsInstall.py 7.17 KB
Newer Older
1
import os,shutil
2
import platform
3
import sip
4 5 6
from windowsSipCompilation import getModuleConfig
from optparse import OptionParser

7
global module2Installfiles
8 9 10 11 12 13 14 15 16 17 18
module2Installfiles = {}
if platform.machine() == 'AMD64':
    module2Installfiles = {
	'core' : [('__init__.py','Lima'),
		  ('common/python/Core.py','Lima'),
		  ('common/python/Debug.py','Lima'),
		  ('build/msvc/9.0/LimaCore/x64/Release/LibLimaCore.dll','Lima'),
		  ('third-party/libconfig/lib/x64/Release/libconfig++.dll','Lima'),
		  ('sip/core/limacore.pyd','Lima'),
		  ('third-party/Processlib/sip/processlib.pyd','Lima'),
		  ('third-party/Processlib/build/msvc/9.0/libprocesslib/x64/Release/libprocesslib.dll','Lima')],
19 20 21 22 23
        'pco' : [('camera/pco/python/Pco.py','Lima'),
                 ('camera/pco/build/msvc/9.0/liblimapco/x64/Release/liblimapco.dll','Lima'),
                 ('camera/pco/sdkPco/bin64/SC2_Cam.dll','Lima'),
                 ('camera/pco/sdkPco/bin64/sc2_cl_me4.dll','Lima'),
                 ('camera/pco/sdkPco/bin64/sc2_clhs.dll','Lima'),
24
                 ('camera/pco/sdkPco/bin64/sc2_clhs_org.dll','Lima'),
25 26
                 ('camera/pco/sdkPco/bin64/sc2_clhs_v1.3.32.dll','Lima'),
                 (sip.__file__,''),
27
                 ('applications/tango/python/camera/Pco.py','Lima/Server/camera'),
28
                 ('sip/pco/limapco.pyd','Lima')],
29 30 31 32
	'dexela' : [('camera/dexela/python/Dexela.py','Lima'),
		    ('camera/dexela/src/DexelaConfig.cfg','Lima'),
		    ('camera/dexela/build/msvc/9.0/LibDexela/x64/Release/liblimadexela.dll','Lima'),
		    ('sip/dexela/limadexela.pyd','Lima')],
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
	}
else:
    module2Installfiles = {
        'core' : [('__init__.py','Lima'),
                  ('common/python/Core.py','Lima'),
                  ('common/python/Debug.py','Lima'),
                  ('build/msvc/9.0/LimaCore/Release/LibLimaCore.dll','Lima'),
                  ('third-party\libconfig\lib\libconfig++.Release\libconfig++.dll','Lima'),
                  ('sip/core/limacore.pyd','Lima'),
                  ('third-party/Processlib/sip/processlib.pyd','Lima'),
                  ('third-party/Processlib/build/msvc/9.0/libprocesslib/Release/libprocesslib.dll','Lima')],
        'pco' : [('camera/pco/python/Pco.py','Lima'),
                 ('camera/pco/build/msvc/9.0/liblimapco/Release/liblimapco.dll','Lima'),
                 ('camera/pco/sdkPco/bin/SC2_Cam.dll','Lima'),
                 ('camera/pco/sdkPco/bin/sc2_cl_me4.dll','Lima'),
48
                 ('applications/tango/python/camera/Pco.py','camera'),
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
                 ('sip/pco/limapco.pyd','Lima')],
        'perkinelmer' : [('camera/perkinelmer/python/PerkinElmer.py','Lima'),
                         ('camera/perkinelmer/build/msvc/9.0/LibPerkinElmer/Release/liblimaperkinelmer.dll','Lima'),
                         ('sip/perkinelmer/limaperkinelmer.pyd','Lima')],
        'photonicscience' : [('camera/photonicscience/python/PhotonicScience.py','Lima'),
                             ('camera/photonicscience/build/msvc/9.0/LibPhotonicScience/Release/liblimaphotonicscience.dll','Lima'),
                             ('camera/photonicscience/sdk/ImageStar4022_v1.7',''),
                             ('sip/photonicscience/limaphotonicscience.pyd','Lima')],
        'simulator' : [('camera/simulator/python/Simulator.py','Lima'),
                       ('camera/simulator/build/msvc/9.0/LibSimulator/Release/liblimasimulator.dll','Lima'),
                       ('sip/simulator/limasimulator.pyd','Lima')],
        'basler' : [('camera/basler/python/Basler.py','Lima'),
                    ('camera/basler/build/msvc/9.0/LibBasler/Release/liblimabasler.dll','Lima'),
                    ('sip/basler/limabasler.pyd','Lima')],
	}
#Add Src 
module2Installfiles.update({
66 67 68 69 70 71 72
    'tango-core' : [('applications/tango/python/LimaCCDs.py','Lima/Server'),
		    ('applications/tango/python/AttrHelper.py','Lima/Server'),
                    ('applications/tango/python/EnvHelper.py','Lima/Server'),
                    ('applications/tango/python/camera/__init__.py','Lima/Server/camera'),
                    ('applications/tango/python/camera/__init__.py','Lima/Server'),
		    ('applications/tango/python/plugins','Lima/Server')],
    'tango-simulator' : [('applications/tango/python/camera/Simulator.py','Lima/Server/camera')],
73 74
    'tango-perkinelmer' : [('applications/tango/python/camera/PerkinElmer.py','camera')],
    'tango-dexela' : [('applications/tango/python/camera/Dexela.py','camera')],
75
    }
76
			   )
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

def copyModule(filesList,baseDestPath) :
    for src,dest in filesList:
        dst = os.path.join(baseDestPath,dest)
            
        if not os.access(dst,os.F_OK) :
            print 'Makedir',dst
            os.makedirs(dst)

        if os.path.isdir(src):
            base,srcDir = os.path.split(src)
            dst = os.path.join(dst,srcDir)
            if os.access(dst,os.F_OK) :
                shutil.rmtree(dst)
            shutil.copytree(src,dst)
            print 'Copytree',src,dst
        elif not os.access(src,os.F_OK) :
94 95
            base,srcDir = os.path.split(src)
            dstFile = os.path.join(dst,srcDir)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
            f = file(dstFile,'w')
            f.close()
            print 'Create empty file',dstFile
        else:
            shutil.copy(src,dst)
            print 'Copy',src,dst

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("--install_dir",dest="install_dir",default='install',
                      help='install directory path')
    parser.add_option("--add",dest="module_list",action="append",default=[],
                      help="Add a module to install")
    parser.add_option("--set",dest="module_set_list",action="append",
                      help="Set the module list to install, do not read config.inc file")
    parser.add_option("--available-modules",dest="get_module_list_flag",action="store_true",default=False,
112
                      help="List all possible modules to install")
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
    parser.add_option("--all",action="store_true",dest="install_all",default=False,
                      help="install all possible module")
    (option,args) = parser.parse_args()

    destPath = option.install_dir
    
    if option.get_module_list_flag:
        print 'Available Modules:'
        for moduleName in module2Installfiles.keys() :
            print '\t ->',moduleName
    elif option.module_set_list:
        for moduleName in option.module_set_list:
            filesList = module2Installfiles.get(moduleName,None)
            if filesList:
                copyModule(filesList,destPath)
            else:
                print "module : %s doesn't exist" % moduleName
    else:
        if option.install_all:
            module_list = list(module2Installfiles.keys())
        else:
134 135 136 137 138
            dict = getModuleConfig()
            module_list = []
            for key,value in dict.iteritems():
                if value:
                    module_list.append(key)
139
            module_list += option.module_list
140
            module_list += ["core"]
unknown's avatar
unknown committed
141 142
            module_list += ["tango-core"]

143 144 145 146 147 148 149 150
        for moduleName in set(module_list) :
            filesList = module2Installfiles.get(moduleName,None)
            if filesList:
                copyModule(filesList,destPath)
            else:
                print "module : %s doesn't exist" % moduleName