/scripts/scramble/scripts/MySQL_python.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 78 lines · 48 code · 18 blank · 12 comment · 4 complexity · 45eb4ed9cf1c534f48417ec4706f9cd2 MD5 · raw file

  1. import os, sys, shutil
  2. from distutils.sysconfig import get_config_var
  3. def prep_mysql( prepped, args ):
  4. my_version = args['version']
  5. my_srcdir = os.path.join( os.getcwd(), "mysql-%s" % my_version )
  6. # set up environment
  7. os.environ['CC'] = get_config_var('CC')
  8. os.environ['CFLAGS'] = get_config_var('CFLAGS')
  9. os.environ['LDFLAGS'] = get_config_var('LDFLAGS')
  10. if '-fPIC' not in os.environ['CFLAGS']:
  11. os.environ['CFLAGS'] += ' -fPIC'
  12. # run configure
  13. run( "./configure --prefix=%s/mysql --disable-dependency-tracking --enable-static --disable-shared --without-server --without-uca " %os.getcwd() + \
  14. "--without-libwrap --without-ssl --without-docs --without-man --enable-thread-safe-client --with-named-curses-libs=''",
  15. my_srcdir, "Configuring mysql (./configure)" )
  16. # compile
  17. run( "make", os.path.join( my_srcdir, 'include' ), "Preparing mysql includes (cd include; make)" )
  18. run( "make link_sources", os.path.join( my_srcdir, 'libmysql' ), "Preparing libmysql (cd libmysql; make link_sources)" )
  19. run( "make link_sources", os.path.join( my_srcdir, 'libmysql_r' ), "Preparing libmysql_r (cd libmysql_r; make link_sources)" )
  20. run( "make", os.path.join( my_srcdir, 'libmysql_r' ), "Compiling libmysql_r (cd libmysql_r; make)" )
  21. run( "make", os.path.join( my_srcdir, 'scripts' ), "Preparing scripts (cd scripts; make)" )
  22. # install
  23. run( "make install", os.path.join( my_srcdir, 'include' ), "Installing mysql includes (cd include; make install)" )
  24. run( "make install", os.path.join( my_srcdir, 'libmysql_r' ), "Installing libmysql_r (cd libmysql_r; make install)" )
  25. run( "make install", os.path.join( my_srcdir, 'scripts' ), "Installing mysql scripts (cd scripts; make install)" )
  26. shutil.copy( os.path.join( my_srcdir, 'include', 'mysqld_error.h' ), os.path.join( 'mysql', 'include', 'mysql' ) )
  27. # create prepped archive
  28. print "%s(): Creating prepped archive for future builds at:" % sys._getframe().f_code.co_name
  29. print " ", prepped
  30. compress( prepped,
  31. 'mysql/bin/mysql_config',
  32. 'mysql/include',
  33. 'mysql/lib' )
  34. if __name__ == '__main__':
  35. # change back to the build dir
  36. if os.path.dirname( sys.argv[0] ) != "":
  37. os.chdir( os.path.dirname( sys.argv[0] ) )
  38. # find setuptools
  39. sys.path.append( os.path.abspath( os.path.join( '..', '..', '..', 'lib' ) ) )
  40. from scramble_lib import *
  41. tag = get_tag()
  42. my_version = ( tag.split( '_' ) )[1]
  43. my_archive_base = os.path.join( archives, 'mysql-%s' % my_version )
  44. my_archive = get_archive( my_archive_base )
  45. my_archive_prepped = os.path.join( archives, 'mysql-%s-%s.tar.gz' % ( my_version, platform_noucs ) )
  46. # clean up any existing stuff (could happen if you run scramble.py by hand)
  47. clean( [ 'mysql-%s' % my_version, 'mysql' ] )
  48. # unpack mysql
  49. unpack_dep( my_archive, my_archive_prepped, prep_mysql, dict( version=my_version ) )
  50. # get site.cfg
  51. shutil.copy( os.path.join( patches, 'MySQL_python', 'site.cfg' ), 'site.cfg' )
  52. # tag
  53. me = sys.argv[0]
  54. sys.argv = [ me ]
  55. if tag is not None:
  56. sys.argv.append( "egg_info" )
  57. sys.argv.append( "--tag-build=%s" %tag )
  58. sys.argv.append( "bdist_egg" )
  59. # go
  60. execfile( "setup.py", globals(), locals() )