Home | Trees | Indices | Help |
---|
|
1 ################################################################################ 2 # Ganga Project. http://cern.ch/ganga 3 # 4 # $Id: PACKAGE.py,v 1.7 2009-07-27 15:15:56 moscicki Exp $ 5 ################################################################################ 6 7 """ PACKAGE modules describe the installation and setup of the Ganga runtime packages. 8 Purpose: automatic initialization of Ganga environment setup and software distribution tools. 9 10 Each PACKAGE module should provide: 11 - setup object : an instance of Ganga.Utility.Setup.PackageSetup class 12 - standardSetup() function 13 14 The setup object is used to describe the external dependencies of the package. 15 The standardSetup() function is used to perform automatic initialization of the environment of the package. 16 """ 17 18 # Default minimum Python version number asked for by Ganga 19 _defaultMinVersion = "2.2" 20 _defaultMinHexVersion = 0x20200f0 21 22 # The default values will be guessed but you may override them here 23 _defaultPlatform = None #'slc3_gcc323' 24 _defaultExternalHome = None 25 #_defaultExternalHome = "/afs/cern.ch/sw/ganga/external/" 26 27 # The dictionary of external packages is used by the release/download 28 # system to handle the installation tarballs. Make sure that all your 29 # dependencies go in here 30 # 31 # The layout of the external tree is fixed. The package top is: 32 # externalHome/name/version/platf 33 # 34 # This layout is similar to LCG external software repository and thus 35 # may be profitable in the long term. 36 # 37 # syspath specifies the relative path for PYTHONPATH setup (sys.path) 38 # if noarch=1 then platf is ommited 39 # 40 # if a path-like variable (e.g. LD_LIBRARY_PATH) is set using setup.prependPath() method, the 41 # value specified in the dictionary may be either string or a list of strings (they will be separated by colons ':'). 42 # 43 _externalPackages = { 44 'Optik' : {'version' : '1.4.1', 45 'noarch':True, 46 'syspath' : 'lib/python2.2/site-packages', 47 'maxHexVersion' : '0x20300f0'}, #maximum Python version number for adding Optik to path 48 'ipython': {'version' : '0.6.13_ganga_patch1', 49 'noarch':True, 50 'PYTHONPATH' : 'lib/python'}, 51 'ApMon' : {'version' : '2.2.11', 52 'noarch':True, 53 'syspath' : 'python'}, 54 'subprocess':{'version' : '2.4.2', 55 'syspath' : 'lib/python2.2/site-packages', 56 'maxHexVersion' : '0x20501f0', # in 2.5.0 subprocess is broken, bugfix: http://savannah.cern.ch/bugs/?36178 57 'noarch':True}, 58 'tarfile':{'version' : '2.4.2', 59 'syspath': 'lib/python2.2/site-packages', 60 'maxHexVersion' : '0x20300f0', 61 'noarch':True}, 62 'paramiko' : {'version' : '1.7.3', 63 'noarch':True, 64 'syspath':'lib/python2.3/site-packages'}, 65 'pycrypto' : {'version' : '2.0.1', 66 'syspath':'lib/python2.3/site-packages'}, 67 'stomputil' : {'version' : '2.3', 68 'noarch': True, 69 'syspath' : 'python'} 70 } 71 7274 """ Try to guess the platform string according to the operating system, current environment and python interpreter. 75 Ganga provides precompiled external packages on a limited set of _default platforms_ as explained in: 76 https://twiki.cern.ch/twiki/bin/view/ArdaGrid/GangaSupportedPlatforms 77 This function is set only to detect the well-known platform strings as defined by the LCG SPI project and is not meant to be a 78 generic platform detection utility. If the platform cannot be guessed a default one is returned. This may or may not work on 79 other systems. In this case you should resolve the external binary dependencies yourself. 80 81 Comments about current implementations: 82 83 SLC5 platform is detected using platform module. 84 85 If it's not SLC5 then: 86 87 We assume that 64 bit python implies the slc4, amd64 system. 88 We assume that 32 bit python implies the slc4, ia32 system. 89 90 We ignore IA64 architecture (Opteron) as not frequently used. 91 92 """ 93 94 # assume INTEL processors (i386, i686,x64), ignore IA64 architecture 95 platf4 = { 32: 'slc4_ia32_gcc34', 64: 'slc4_amd64_gcc34'} 96 platf5 = { 32: 'i686-slc5-gcc43-opt', 64: 'x86_64-slc5-gcc43-opt'} 97 98 # for older python versions use some tricks 99 import sys 100 bits = sys.maxint >> 32 101 102 if bits: arch = 64 103 else: 104 arch = 32 105 106 platfstring = platf4 107 108 try: 109 import platform 110 import re 111 c = re.compile('\S+-redhat-(?P<ver>\S+)-\S+') 112 r = c.match(platform.platform()) 113 if r and r.group('ver').split('.')[0] == '5': 114 platfstring = platf5 115 except ImportError: 116 pass 117 118 return platfstring[arch]119 120 121 # guess defaults if not defined 122 if not _defaultExternalHome: 123 import os.path 124 import Ganga 125 from Ganga.Utility.files import fullpath 126 p = fullpath(Ganga.__file__) 127 for i in range(5): 128 p = os.path.dirname(p) 129 _defaultExternalHome = os.path.join(p,'external') 130 131 if not _defaultPlatform: 132 _defaultPlatform = detectPlatform() 133 134 from Ganga.Utility.Setup import PackageSetup 135 # The setup object 136 setup = PackageSetup(_externalPackages) 137139 """ Perform automatic initialization of the environment of the package. 140 The gangaDir argument is only used by the core package, other packages should have no arguments. 141 """ 142 143 from Ganga.Utility.Setup import checkPythonVersion 144 import sys 145 146 # here we assume that the Ganga has been already prepended to sys.path by the caller 147 if checkPythonVersion(_defaultMinVersion,_defaultMinHexVersion): 148 for name in setup.packages: 149 if name == 'pycrypto' and sys.hexversion > 0x2050000: 150 # hack the pycrypto path for 2.5 151 setup.packages['pycrypto']['syspath'] = setup.packages['pycrypto']['syspath'].replace('2.3', '2.5') 152 153 if name == 'paramiko' and sys.hexversion > 0x2050000: 154 # hack the paramiko path for 2.5 155 setup.packages['paramiko']['syspath'] = setup.packages['paramiko']['syspath'].replace('2.3', '2.5') 156 157 158 setup.setSysPath(name) 159 setup.prependPath(name,'PYTHONPATH') 160 161 # if other PATH variable must be defined, e.g. LD_LIBRARY_PATH, then 162 # you should do it this way: 163 #setup.prependPath(name,'LD_LIBRARY_PATH') 164 else: 165 sys.exit()166
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Jun 25 10:35:39 2012 | http://epydoc.sourceforge.net |