PageRenderTime 36ms CodeModel.GetById 27ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/scripts/scramble/scripts/DRMAA_python.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 41 lines | 38 code | 2 blank | 1 comment | 4 complexity | 0441c1ae35c81c0d02f7a2088f64740c MD5 | raw file
 1import os, sys, shutil
 2
 3if "SGE_ROOT" not in os.environ:
 4    print "main(): Please set SGE_ROOT to the path of your SGE installation"
 5    print "main(): before scrambling DRMAA_python"
 6    sys.exit(1)
 7
 8# change back to the build dir
 9if os.path.dirname( sys.argv[0] ) != "":
10    os.chdir( os.path.dirname( sys.argv[0] ) )
11
12# find setuptools
13sys.path.append( os.path.join( '..', '..', '..', 'lib' ) )
14from scramble_lib import *
15
16tag = get_tag() # get the tag
17clean() # clean up any existing stuff (could happen if you run scramble.py by hand)
18
19# patch
20file = "setup.py"
21print "main(): Patching", file
22if not os.access( "%s.orig" %file, os.F_OK ):
23    shutil.copyfile( file, "%s.orig" %file )
24i = open( "%s.orig" %file, "r" )
25o = open( file, "w" )
26for line in i.readlines():
27    if line == 'SGE6_ROOT="/scratch_test02/SGE6"\n':
28        line = 'SGE6_ROOT="%s"\n' % os.environ["SGE_ROOT"]
29    if line.startswith('link_args ='):
30        line = 'link_args = [ "-L%s" % os.path.join(SGE6_ROOT, "lib", SGE6_ARCH), "-Wl,-R%s" % os.path.join(SGE6_ROOT, "lib", SGE6_ARCH),  "-ldrmaa"  ]\n'
31    print >>o, line,
32i.close()
33o.close()
34
35# reset args for distutils
36me = sys.argv[0]
37sys.argv = [ me ]
38sys.argv.append( "bdist_egg" )
39
40# do it
41execfile( "setup.py", globals(), locals() )