From 83daeb74bb9ddbdc4088fc1ab5b45cf61ae3055b Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 30 May 2008 20:18:03 +0000 Subject: [PATCH] It doesn't make sense to even distribute DRMAA_python eggs. So instead of downloading its own SGE and linking, scramble now just links to a user-supplied SGE in $SGE_ROOT. Added a seperate script to make it build right on sparc/x86 32/64 Solaris. --- .../scramble/scripts/DRMAA_python-macosx.py | 104 ------------------ .../scramble/scripts/DRMAA_python-solaris.py | 81 ++++++++++++++ scripts/scramble/scripts/DRMAA_python.py | 72 ++---------- 3 files changed, 91 insertions(+), 166 deletions(-) delete mode 100644 scripts/scramble/scripts/DRMAA_python-macosx.py create mode 100644 scripts/scramble/scripts/DRMAA_python-solaris.py diff --git a/scripts/scramble/scripts/DRMAA_python-macosx.py b/scripts/scramble/scripts/DRMAA_python-macosx.py deleted file mode 100644 index 993717c8186..00000000000 --- a/scripts/scramble/scripts/DRMAA_python-macosx.py +++ /dev/null @@ -1,104 +0,0 @@ -import os, sys, subprocess, tarfile, shutil, urllib2 - -def unpack_sge(): - os.makedirs( "gridengine" ) - for file in [ SGE_COMMON_ARCHIVE, SGE_BINARY_PPC_ARCHIVE, SGE_BINARY_X86_ARCHIVE ]: - if not os.access( file, os.F_OK ): - fetch( file ) - t = tarfile.open( file, "r" ) - print "unpack_sge() Unpacking:" - print " ", file - for fn in t.getnames(): - t.extract( fn, "gridengine" ) - t.close() - -def lipo(): - darwin_dir = os.path.join( "gridengine", "lib", "darwin" ) - os.rename( "%s-ppc" % darwin_dir, "%s-ppc.orig" % darwin_dir ) - os.rename( "%s-x86" % darwin_dir, "%s-x86.orig" % darwin_dir ) - os.makedirs( darwin_dir ) - os.symlink( "darwin", "%s-ppc" % darwin_dir ) - os.symlink( "darwin", "%s-x86" % darwin_dir ) - ppc_libdrmaa = os.path.join( "%s-ppc.orig" % darwin_dir, "libdrmaa.dylib.1.0" ) - x86_libdrmaa = os.path.join( "%s-x86.orig" % darwin_dir, "libdrmaa.dylib.1.0" ) - fat_libdrmaa = os.path.join( darwin_dir, "libdrmaa.dylib.1.0" ) - lipo_cmd = "lipo %s %s -create -output %s" % ( ppc_libdrmaa, x86_libdrmaa, fat_libdrmaa ) - os.symlink( "libdrmaa.dylib.1.0", os.path.join( darwin_dir, "libdrmaa.dylib" ) ) - p = subprocess.Popen( args = lipo_cmd, shell = True ) - r = p.wait() - if r != 0: - print "lipo(): lipo failed" - sys.exit( 1 ) - -def fetch( file ): - url = SGE_BASE_URL + os.path.basename( file ) - print "fetch(): Fetching:" - print " ", url - inf = urllib2.urlopen( url ) - otf = open( file, 'wb' ) - otf.write( inf.read() ) - inf.close() - otf.close() - -# change back to the build dir -if os.path.dirname( sys.argv[0] ) != "": - os.chdir( os.path.dirname( sys.argv[0] ) ) - -# find setuptools -scramble_lib = os.path.join( "..", "..", "..", "lib" ) -sys.path.append( scramble_lib ) -try: - from setuptools import * - import pkg_resources -except: - from ez_setup import use_setuptools - use_setuptools( download_delay=8, to_dir=scramble_lib ) - from setuptools import * - import pkg_resources - -# get the tag -if os.access( ".galaxy_tag", os.F_OK ): - tagfile = open( ".galaxy_tag", "r" ) - tag = tagfile.readline().strip() -else: - tag = None - -SGE_VERSION = ( tag.split( "_" ) )[1] -SGE_BASE_URL = "http://gridengine.sunsource.net/download/SGE61/" -SGE_COMMON_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "ge-%s-common.tar.gz" %SGE_VERSION ) ) -SGE_BINARY_PPC_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "ge-%s-bin-darwin-ppc.tar.gz" % SGE_VERSION ) ) -SGE_BINARY_X86_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "ge-%s-bin-darwin-x86.tar.gz" % SGE_VERSION ) ) - -# clean, in case you're running this by hand from a dirty module source dir -for dir in [ "build", "dist", "gridengine" ]: - if os.access( dir, os.F_OK ): - print "scramble_it.py: removing dir:", dir - shutil.rmtree( dir ) - -# build/unpack SGE -unpack_sge() -lipo() - -file = "setup.py" -print "scramble(): Patching", file -if not os.access( "%s.orig" %file, os.F_OK ): - shutil.copyfile( file, "%s.orig" %file ) -i = open( "%s.orig" %file, "r" ) -o = open( file, "w" ) -for line in i.readlines(): - if line == 'SGE6_ROOT="/scratch_test02/SGE6"\n': - line = 'SGE6_ROOT="gridengine"\n' - print >>o, line, -i.close() -o.close() - -# tag -me = sys.argv[0] -sys.argv = [ me ] -if tag is not None: - sys.argv.append( "egg_info" ) - sys.argv.append( "--tag-build=%s" %tag ) -sys.argv.append( "bdist_egg" ) - -# go -execfile( "setup.py", globals(), locals() ) diff --git a/scripts/scramble/scripts/DRMAA_python-solaris.py b/scripts/scramble/scripts/DRMAA_python-solaris.py new file mode 100644 index 00000000000..3da075d6e6e --- /dev/null +++ b/scripts/scramble/scripts/DRMAA_python-solaris.py @@ -0,0 +1,81 @@ +import os, sys, shutil + +if "SGE_ROOT" not in os.environ: + print "scramble(): Please set SGE_ROOT to the path of your SGE installation" + print "scramble(): before scrambling DRMAA_python" + sys.exit(1) + +# change back to the build dir +if os.path.dirname( sys.argv[0] ) != "": + os.chdir( os.path.dirname( sys.argv[0] ) ) + +# find setuptools +scramble_lib = os.path.join( "..", "..", "..", "lib" ) +sys.path.append( scramble_lib ) +try: + from setuptools import * + import pkg_resources +except: + from ez_setup import use_setuptools + use_setuptools( download_delay=8, to_dir=scramble_lib ) + from setuptools import * + import pkg_resources + +# clean, in case you're running this by hand from a dirty module source dir +for dir in [ "build", "dist", "gridengine" ]: + if os.access( dir, os.F_OK ): + print "scramble_it.py: removing dir:", dir + shutil.rmtree( dir ) + +# if our python is 64 bit, use 64 bit sge... +if sys.maxint < ( 2048 * 1024 * 1024 ): + if sys.byteorder == 'big': + arch = "sparc" + else: + arch = "x86" +else: + if sys.byteorder == 'big': + arch = "sparc64" + else: + arch = "amd64" + if not "CFLAGS" in os.environ: + os.environ["CFLAGS"] = "" + os.environ["CFLAGS"] += " -m64" + +# if we're using sun cc, drop the gcc -Wno-unused option +import distutils.sysconfig +cc = distutils.sysconfig.get_config_var('CC') +if os.popen( cc + ' --version 2>&1' ).read().strip().split('\n')[0].startswith('gcc'): + compiler = 'gcc' +elif os.popen( cc + ' -V 2>&1' ).read().strip().split('\n')[0].startswith('cc: Sun C'): + compiler = 'sun' +else: + print "scramble(): Unable to determine compiler" + sys.exit(1) + +# patch +file = "setup.py" +print "scramble(): Patching", file +if not os.access( "%s.orig" %file, os.F_OK ): + shutil.copyfile( file, "%s.orig" %file ) +i = open( "%s.orig" %file, "r" ) +o = open( file, "w" ) +for line in i.readlines(): + if line == 'SGE6_ROOT="/scratch_test02/SGE6"\n': + line = 'SGE6_ROOT="%s"\n' % os.environ["SGE_ROOT"] + elif line.startswith('SGE6_ARCH='): + line = 'SGE6_ARCH="sol-%s"\n' % arch + elif line.startswith('link_args ='): + 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' + if line == " + [ '-Wno-unused' ]\n": + if compiler == 'sun': + line = " #+ [ '-Wno-unused' ]\n" + print >>o, line, +i.close() +o.close() + +# go +me = sys.argv[0] +sys.argv = [ me ] +sys.argv.append( "bdist_egg" ) +execfile( "setup.py", globals(), locals() ) diff --git a/scripts/scramble/scripts/DRMAA_python.py b/scripts/scramble/scripts/DRMAA_python.py index 34f33d5326a..e55155f8b61 100644 --- a/scripts/scramble/scripts/DRMAA_python.py +++ b/scripts/scramble/scripts/DRMAA_python.py @@ -1,32 +1,9 @@ -import os, sys, subprocess, tarfile, shutil, urllib2 +import os, sys, shutil -def unpack_sge(): - os.makedirs( "gridengine" ) - for file in [ SGE_COMMON_ARCHIVE, SGE_BINARY_ARCHIVE ]: - if not os.access( file, os.F_OK ): - fetch( file ) - t = tarfile.open( file, "r" ) - print "unpack_sge() Unpacking:" - print " ", file - for fn in t.getnames(): - t.extract( fn, "gridengine" ) - t.close() - # i doubt you're using a 64 bit python, but if you are, this will break things - if arch == "sol-x86": - os.symlink( "sol-x86", os.path.join( "gridengine", "lib", "sol-amd64" ) ) - if arch == "sol-sparc64": - os.rename( os.path.join( "gridengine", "lib", "sol-sparc64" ), os.path.join( "gridengine", "lib", "sol-sparc64.orig" ) ) - os.symlink( "sol-sparc", os.path.join( "gridengine", "lib", "sol-sparc64" ) ) - -def fetch( file ): - url = SGE_BASE_URL + os.path.basename( file ) - print "fetch(): Fetching:" - print " ", url - inf = urllib2.urlopen( url ) - otf = open( file, 'wb' ) - otf.write( inf.read() ) - inf.close() - otf.close() +if "SGE_ROOT" not in os.environ: + print "scramble(): Please set SGE_ROOT to the path of your SGE installation" + print "scramble(): before scrambling DRMAA_python" + sys.exit(1) # change back to the build dir if os.path.dirname( sys.argv[0] ) != "": @@ -44,39 +21,13 @@ except: from setuptools import * import pkg_resources -# get the tag -if os.access( ".galaxy_tag", os.F_OK ): - tagfile = open( ".galaxy_tag", "r" ) - tag = tagfile.readline().strip() -else: - tag = None - -SGE_VERSION = ( tag.split( "_" ) )[1] - -platform = pkg_resources.get_platform() -if platform.startswith( 'solaris' ): - if platform.endswith( 'i86pc' ): - arch = 'sol-x86' - elif platform.endswith( 'sun4u' ): - arch = 'sol-sparc64' -elif platform == 'linux-i686': - arch = 'lx24-x86' -elif platform == 'linux-x86_64': - arch = 'lx24-amd64' - -SGE_BASE_URL = "http://gridengine.sunsource.net/download/SGE61/" -SGE_COMMON_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "ge-%s-common.tar.gz" %SGE_VERSION ) ) -SGE_BINARY_ARCHIVE = os.path.abspath( os.path.join( "..", "..", "..", "archives", "ge-%s-bin-%s.tar.gz" %( SGE_VERSION, arch ) ) ) - # clean, in case you're running this by hand from a dirty module source dir for dir in [ "build", "dist", "gridengine" ]: if os.access( dir, os.F_OK ): print "scramble_it.py: removing dir:", dir shutil.rmtree( dir ) -# build/unpack SGE -unpack_sge() - +# patch file = "setup.py" print "scramble(): Patching", file if not os.access( "%s.orig" %file, os.F_OK ): @@ -85,18 +36,15 @@ i = open( "%s.orig" %file, "r" ) o = open( file, "w" ) for line in i.readlines(): if line == 'SGE6_ROOT="/scratch_test02/SGE6"\n': - line = 'SGE6_ROOT="gridengine"\n' + line = 'SGE6_ROOT="%s"\n' % os.environ["SGE_ROOT"] + if line.startswith('link_args ='): + 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' print >>o, line, i.close() o.close() -# tag +# go me = sys.argv[0] sys.argv = [ me ] -if tag is not None: - sys.argv.append( "egg_info" ) - sys.argv.append( "--tag-build=%s" %tag ) sys.argv.append( "bdist_egg" ) - -# go execfile( "setup.py", globals(), locals() )