PageRenderTime 59ms CodeModel.GetById 48ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/scripts/scramble/scripts/DRMAA_python-macosx.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 49 lines | 46 code | 2 blank | 1 comment | 4 complexity | 4b9494fef3dc1f33d96653ace3288292 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), "-ldrmaa"  ]\n'
31    print >>o, line,
32i.close()
33o.close()
34
35# build
36me = sys.argv[0]
37sys.argv = [ me ]
38sys.argv.append( "build" )
39execfile( "setup.py", globals(), locals() )
40
41# fix _cDRMAA.so rpath
42so = "build/lib.%s-%s/_cDRMAA.so" % ( pkg_resources.get_platform(), sys.version[:3] )
43libdrmaa = os.path.join(SGE6_ROOT, "lib", SGE6_ARCH, "libdrmaa.dylib.1.0" )
44os.system( "install_name_tool -change libdrmaa.dylib.1.0 %s %s" % ( libdrmaa, so ) )
45
46# package
47sys.argv = [ me ]
48sys.argv.append( "bdist_egg" )
49execfile( "setup.py", globals(), locals() )