PageRenderTime 24ms CodeModel.GetById 2ms app.highlight 17ms RepoModel.GetById 2ms app.codeStats 0ms

/scripts/scramble/scripts/MySQL_python.py

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