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

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 49 lines · 35 code · 8 blank · 6 comment · 6 complexity · 4b9494fef3dc1f33d96653ace3288292 MD5 · raw file

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