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

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 82 lines · 52 code · 18 blank · 12 comment · 6 complexity · 0ab8a8d988ff847823f1c3dc0ffbe43b MD5 · raw file

  1. import os, sys, shutil
  2. from distutils.sysconfig import get_config_var
  3. def prep_postgres( prepped, args ):
  4. pg_version = args['version']
  5. pg_srcdir = os.path.join( os.getcwd(), "postgresql-%s" % pg_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. cc = get_solaris_compiler()
  11. if cc == 'cc':
  12. os.environ['CFLAGS'] += ' -KPIC'
  13. elif cc == 'gcc':
  14. os.environ['CFLAGS'] += ' -fPIC -DPIC'
  15. # run configure
  16. run( "./configure --prefix=%s/postgres --disable-dependency-tracking --enable-static --disable-shared --without-readline --with-thread-safety" % os.getcwd(),
  17. os.path.join( os.getcwd(), "postgresql-%s" % pg_version ),
  18. "Configuring postgres (./configure)" )
  19. # compile
  20. 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)" )
  21. run( "gmake", os.path.join( pg_srcdir, 'src', 'interfaces', 'libpq' ), "Compiling libpq (cd src/interfaces/libpq; gmake)" )
  22. run( "gmake", os.path.join( pg_srcdir, 'src', 'bin', 'pg_config' ), "Compiling pg_config (cd src/bin/pg_config; gmake)" )
  23. # install
  24. run( "gmake install", os.path.join( pg_srcdir, 'src', 'interfaces', 'libpq' ), "Compiling libpq (cd src/interfaces/libpq; gmake install)" )
  25. run( "gmake install", os.path.join( pg_srcdir, 'src', 'bin', 'pg_config' ), "Compiling pg_config (cd src/bin/pg_config; gmake install)" )
  26. run( "gmake install", os.path.join( pg_srcdir, 'src', 'include' ), "Compiling pg_config (cd src/include; gmake install)" )
  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. 'postgres/bin',
  32. 'postgres/include',
  33. 'postgres/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. pg_version = ( tag.split( "_" ) )[1]
  43. pg_archive_base = os.path.join( archives, "postgresql-%s" % pg_version )
  44. pg_archive = get_archive( pg_archive_base )
  45. pg_archive_prepped = os.path.join( archives, "postgresql-%s-%s.tar.gz" % ( pg_version, platform_noucs ) )
  46. # clean up any existing stuff (could happen if you run scramble.py by hand)
  47. clean( [ 'postgresql-%s' % pg_version ] )
  48. # unpack postgres
  49. unpack_dep( pg_archive, pg_archive_prepped, prep_postgres, dict( version=pg_version ) )
  50. # localize setup.cfg
  51. if not os.path.exists( 'setup.cfg.orig' ):
  52. shutil.copy( 'setup.cfg', 'setup.cfg.orig' )
  53. f = open( 'setup.cfg', 'a' )
  54. f.write( '\npg_config=postgres/bin/pg_config\n' )
  55. f.close()
  56. # tag
  57. me = sys.argv[0]
  58. sys.argv = [ me ]
  59. if tag is not None:
  60. sys.argv.append( "egg_info" )
  61. sys.argv.append( "--tag-build=%s" %tag )
  62. sys.argv.append( "bdist_egg" )
  63. # go
  64. execfile( "setup.py", globals(), locals() )