PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/scripts/scramble/scripts/psycopg2-solaris.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 82 lines | 66 code | 10 blank | 6 comment | 3 complexity | 0ab8a8d988ff847823f1c3dc0ffbe43b MD5 | raw file
 1import os, sys, shutil
 2from distutils.sysconfig import get_config_var
 3
 4def prep_postgres( prepped, args ):
 5
 6    pg_version = args['version']
 7    pg_srcdir = os.path.join( os.getcwd(), "postgresql-%s" % pg_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    cc = get_solaris_compiler()
15    if cc == 'cc':
16        os.environ['CFLAGS'] += ' -KPIC'
17    elif cc == 'gcc':
18        os.environ['CFLAGS'] += ' -fPIC -DPIC'
19
20    # run configure
21    run( "./configure --prefix=%s/postgres --disable-dependency-tracking --enable-static --disable-shared --without-readline --with-thread-safety" % os.getcwd(),
22        os.path.join( os.getcwd(), "postgresql-%s" % pg_version ),
23        "Configuring postgres (./configure)" )
24
25    # compile
26    run( "gmake ../../src/include/utils/fmgroids.h", os.path.join( pg_srcdir, 'src', 'backend' ), "Compiling fmgroids.h (cd src/backend; gmake ../../src/include/utils/fmgroids.h)" )
27    run( "gmake", os.path.join( pg_srcdir, 'src', 'interfaces', 'libpq' ), "Compiling libpq (cd src/interfaces/libpq; gmake)" )
28    run( "gmake", os.path.join( pg_srcdir, 'src', 'bin', 'pg_config' ), "Compiling pg_config (cd src/bin/pg_config; gmake)" )
29
30    # install
31    run( "gmake install", os.path.join( pg_srcdir, 'src', 'interfaces', 'libpq' ), "Compiling libpq (cd src/interfaces/libpq; gmake install)" )
32    run( "gmake install", os.path.join( pg_srcdir, 'src', 'bin', 'pg_config' ), "Compiling pg_config (cd src/bin/pg_config; gmake install)" )
33    run( "gmake install", os.path.join( pg_srcdir, 'src', 'include' ), "Compiling pg_config (cd src/include; gmake install)" )
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           'postgres/bin',
40           'postgres/include',
41           'postgres/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    pg_version = ( tag.split( "_" ) )[1]
56    pg_archive_base = os.path.join( archives, "postgresql-%s" % pg_version )
57    pg_archive = get_archive( pg_archive_base )
58    pg_archive_prepped = os.path.join( archives, "postgresql-%s-%s.tar.gz" % ( pg_version, platform_noucs ) )
59
60    # clean up any existing stuff (could happen if you run scramble.py by hand)
61    clean( [ 'postgresql-%s' % pg_version ] )
62
63    # unpack postgres
64    unpack_dep( pg_archive, pg_archive_prepped, prep_postgres, dict( version=pg_version ) )
65
66    # localize setup.cfg
67    if not os.path.exists( 'setup.cfg.orig' ):
68        shutil.copy( 'setup.cfg', 'setup.cfg.orig' )
69        f = open( 'setup.cfg', 'a' )
70        f.write( '\npg_config=postgres/bin/pg_config\n' )
71        f.close()
72
73    # tag
74    me = sys.argv[0]
75    sys.argv = [ me ]
76    if tag is not None:
77        sys.argv.append( "egg_info" )
78        sys.argv.append( "--tag-build=%s" %tag )
79    sys.argv.append( "bdist_egg" )
80
81    # go
82    execfile( "setup.py", globals(), locals() )