forked from DIRACGrid/Externals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirac-make.py
executable file
·86 lines (65 loc) · 2.6 KB
/
dirac-make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
import imp, os, sys, urllib
import logging
logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s')
here = os.path.dirname( os.path.abspath( __file__ ) )
chFilePath = os.path.join( os.path.dirname( here ) , "common", "CompileHelper.py" )
try:
fd = open( chFilePath )
except Exception as e:
print "Cannot open %s: %s" % ( chFilePath, e )
sys.exit( 1 )
chModule = imp.load_module( "CompileHelper", fd, chFilePath, ( ".py", "r", imp.PY_SOURCE ) )
fd.close()
chClass = getattr( chModule, "CompileHelper" )
ch = chClass( here )
versions = { 'Python' : "2.7.8" }
prefix = ch.getPrefix()
libDirs = []
for i in ( "lib", "lib64" ):
libPath = os.path.join( prefix, i )
if os.path.isdir( libPath ):
libDirs.append( libPath )
env = {}
env[ 'LD_LIBRARY_PATH' ] = ":".join( libDirs )
if 'LD_LIBRARY_PATH' in os.environ:
env[ 'LD_LIBRARY_PATH' ] += ":%s" % os.environ[ 'LD_LIBRARY_PATH' ]
env[ 'CPPFLAGS' ] = "-I%s/include -I%s/include/ncurses" % ( prefix, prefix )
#env[ 'CFLAGS' ] = "-I%s/include -I%s/include/ncurses" % ( prefix, prefix )
env[ 'LDFLAGS' ] = " ".join( [ "-L%s" % libPath for libPath in libDirs ] )
print env
ch.setDefaultEnv( env )
darwinVer = ch.getDarwinVersion()
pythonFile = "Python-%s.tgz" % versions[ 'Python' ]
pythonFilePath = os.path.join( here, pythonFile )
if not os.path.isfile( pythonFilePath ):
try:
urllib.urlretrieve( "http://python.org/ftp/python/%s/%s" % ( versions[ 'Python' ], pythonFile ),
os.path.join( here, pythonFile ) )
except Exception as e:
logging.error( "Could not retrieve python 2.7: %s", e )
sys.exit( 1 )
ch.setPackageVersions( versions )
if True:
if not ch.unTarPackage( "Python" ):
logging.error( "Could not untar python" )
sys.exit( 1 )
prefix = ch.getPrefix()
#configureArgs = "CFLAGS='-L%s/lib' CPPFLAGS='-I%s/include -I%s/include/ncurses'" % ( prefix, prefix, prefix )
configureArgs = " --enable-shared --enable-static --enable-unicode=ucs4 "
if not ch.doConfigure( "Python", extraArgs = configureArgs ):
logging.error( "Could not deploy Python" )
sys.exit( 1 )
for func in ( ch.doMake, ch.doInstall ):
if not func( "Python" ):
logging.error( "Could not deploy Python" )
sys.exit( 1 )
if not ch.pythonExec( os.path.join( here, "distribute_setup.py" ) ):
logging.error( "Could not install distribute" )
sys.exit( 1 )
if not ch.pythonExec( os.path.join( here, "ez_setup.py" ) ):
logging.error( "Could not install ez_setup" )
sys.exit( 1 )
if not ch.pythonExec( os.path.join( here, "get-pip.py" ) ):
logging.error( "Could not install pip" )
sys.exit( 1 )