def build_libxslt(): 'needed by webkit and lxml' from compiledeps import libxml2_dirname libxmlabs = abspath(libxml2_dirname) libxmlinc = pathjoin(libxmlabs, 'include') libxmllib = pathjoin(libxmlabs, 'win32', 'bin.msvc') iconvinc = pathjoin(abspath(iconv_dirname), 'include') libxslt_dir = libxslt.get() with cd(libxslt_dir): with cd('libxslt'): ensure_processonenode_is_public() with cd('win32'): patch_libxml2_h('..', 'libxslt') debug_flag = ['debug=yes'] if DEBUG else [] run(['cscript', 'configure.js', '//E:JavaScript', 'vcmanifest=yes'] + debug_flag + ['include=%s' % os.pathsep.join([libxmlinc, iconvinc]), 'lib=%s' % libxmllib]) filerepl('Makefile.msvc', '/O2', '/Os /GL /GS- /Zi') filerepl('Makefile.msvc', 'LDFLAGS = /nologo', 'LDFLAGS = /OPT:REF /OPT:ICF /nologo /DEBUG') run(['nmake', '-f', 'Makefile.msvc'] + (['clean'] if CLEAN else [])) return libxslt_dir
def commit(): print '\nEnter a commit message, or press enter to skip:', message = raw_input() if message: with cd(BINARIES_DEST_DIR): run(['svn', 'commit'] + artifacts + ['-m', message])
def __call__(self, parser, ns, value, option_string): if not value: return print 'running Po', id(self) with buildutil.cd(DIGSBYROOT): default_pot = TEMP_path('digsby_default.pot') sip_pot = TEMP_path('digsby_sip.pot') yaml_pot = TEMP_path('digsby_yaml.pot') tenjin_pot = TEMP_path('digsby_tenjin.pot') input_pots = [default_pot, sip_pot, yaml_pot, tenjin_pot] final_pot = POT_path('digsby') for pot in input_pots: if os.path.isfile(pot): os.remove(pot) xgettext(FIL_PATH, default_pot) # xgettext(FIL_SIP_PATH, sip_pot, '-C') xgettext_yaml(FIL_YAML_PATH, yaml_pot) xgettext(FIL_TENJIN_PATH, tenjin_pot, '-L', 'python') input_pots = filter(lambda pot: os.path.isfile(pot), input_pots) cat = pot_read_clean(input_pots[0]) for potfile in input_pots[1:]: cat_u = pot_read_clean(potfile) for msg in cat_u: cat[msg.id] = msg write_pot(final_pot, cat, version=True) pofiles = [os.path.join(PO_DIR, f) for f in os.listdir(PO_DIR) if f.endswith('.po')] for pofile in pofiles: buildutil.run(['msgmerge', '-F', '--no-wrap', pofile, final_pot, '-o', pofile])
def check_bakefile(): 'Checks for bakefile on PATH.' try: run(['bakefile', '--version']) except Exception: fatal('bakefile is not on PATH: please fix, or download and install from http://www.bakefile.org/download.html')
def xgettext(input_file, output_file, *args): buildutil.run( [ 'xgettext', ] + HEADER + KEYWORDS() + ['--from-code', 'UTF-8', '--no-wrap', '--add-comments=Translators:'] + list(args) + ['--files-from', input_file, '--output', output_file])
def install_stdlib(): 'Copies all the .py files in python/Lib' from buildutil import copy_different with cd(PYTHON_DIR): exclude = '.xcopy.exclude' # have to specify xcopy excludes in a file with open(exclude, 'w') as fout: fout.write('\n'.join(['.pyc', '.pyo', '.svn'])) try: run([ 'xcopy', 'Lib', r'%s\lib' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I', '/E', '/D', '/Y' ]) run([ 'xcopy', 'Include', r'%s\Include' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I', '/E', '/D', '/Y' ]) if not os.path.isdir(r'%s\libs' % DPYTHON_DIR): os.makedirs(r'%s\libs' % DPYTHON_DIR) for f in os.listdir(r'PCBuild'): if f.endswith('.lib'): copy_different(os.path.join('PCBuild', f), os.path.join(r'%s\libs' % DPYTHON_DIR, f)) finally: os.remove(exclude)
def build_libxslt(): 'needed by webkit and lxml' from compiledeps import libxml2_dirname libxmlabs = abspath(libxml2_dirname) libxmlinc = pathjoin(libxmlabs, 'include') libxmllib = pathjoin(libxmlabs, 'win32', 'bin.msvc') iconvinc = pathjoin(abspath(iconv_dirname), 'include') libxslt_dir = libxslt.get() with cd(libxslt_dir): with cd('libxslt'): ensure_processonenode_is_public() with cd('win32'): patch_libxml2_h('..', 'libxslt') debug_flag = ['debug=yes'] if DEBUG else [] run([ 'cscript', 'configure.js', '//E:JavaScript', 'vcmanifest=yes' ] + debug_flag + [ 'include=%s' % os.pathsep.join([libxmlinc, iconvinc]), 'lib=%s' % libxmllib ]) filerepl('Makefile.msvc', '/O2', '/Os /GL /GS- /Zi') filerepl('Makefile.msvc', 'LDFLAGS = /nologo', 'LDFLAGS = /OPT:REF /OPT:ICF /nologo /DEBUG') run(['nmake', '-f', 'Makefile.msvc'] + (['clean'] if CLEAN else [])) return libxslt_dir
def check_bakefile(): 'Checks for bakefile on PATH.' try: run(['bakefile', '--version']) except Exception: fatal( 'bakefile is not on PATH: please fix, or download and install from http://www.bakefile.org/download.html' )
def sip(): sip_path_parent, sip_dir = os.path.split(os.path.abspath(sip_path)) # Get SIP needs_build = True with cd(sip_path_parent): if not isdir(sip_dir): inform('Could not find SIP directory at %r, downloading...' % sip_path) git.run(['clone', SIP_GIT_REPO, sip_dir]) if SIP_GIT_BRANCH != 'master': with cd(sip_dir): git.run([ 'checkout', '-b', SIP_GIT_BRANCH, SIP_GIT_REMOTE + '/' + SIP_GIT_BRANCH ]) else: pass # inform('SIP found at %r, updating...' % sip_path) # with cd(sip_dir): # git.run(['pull']) # if not git.sha_changed() and isfile(sip_exe) and isfile(sip_pyd): # inform('skipping SIP build') # needs_build = False # Build SIP if needs_build and 'nosip' not in sys.argv: with cd(sip_path): if not sys.platform.startswith("win"): dpy([ 'configure.py', '-b', 'sipgen', '-d', 'siplib', '-e', 'siplib', '-v', 'siplib' ]) # sip sets CC and CXX directly to cc and c++ rather than pulling the values # from the environment, which we don't want if we're forcing a 32-bit build # by using gcc 4.0. env = os.environ run([ 'make', 'CC=%s' % env['CC'], 'CXX=%s' % env['CXX'], 'LINK=%s' % env['CXX'] ]) else: dpy(['setup.py', 'build']) assert isfile(sip_exe), "setup.py did not create %s" % sip_exe if sys.platform.startswith("win"): from buildutil import copy_different, DEPS_DIR copy_different(sip_pyd, DEPS_DIR) copy_different(sip_pdb, DEPS_DIR)
def xgettext(input_file, output_file, *args): buildutil.run(['xgettext', ] + HEADER + KEYWORDS() + [ '--from-code', 'UTF-8', '--no-wrap', '--add-comments=Translators:'] + list(args) + ['--files-from', input_file, '--output', output_file])
def update(): 'Updates the Python source tree.' with cd(PYTHON_DIR): if PYTHON_SVN_REVISION == 'HEAD' or svn_version('.') != int(PYTHON_SVN_REVISION): inform('updating python') run(['svn', 'update', '-r', PYTHON_SVN_REVISION]) return True else: return False
def update(): 'Updates the Python source tree.' with cd(PYTHON_DIR): if PYTHON_SVN_REVISION == 'HEAD' or svn_version('.') != int( PYTHON_SVN_REVISION): inform('updating python') run(['svn', 'update', '-r', PYTHON_SVN_REVISION]) return True else: return False
def check_swig(): 'Checks for the correct version of SWIG.' try: run(['swig', '-version'], checkret = False) except Exception: fatal(SWIG_MSG) if not 'SWIG_LIB' in os.environ: fatal("ERROR: no SWIG_LIB\n" "please set SWIG_LIB in your environment to the Lib folder " "underneath Swig's installation folder")
def build(force_bakefile=False): abs_wxdir = abspath(WXDIR) os.environ.update( WXWIN=abspath(WXDIR), WXDIR=abspath(WXDIR), #CAIRO_ROOT = abspath(pathjoin(WXDIR, 'external', 'cairo-dev')), ) copy_setup_h() check_bakefile() msw_makefile = pathjoin(WXDIR, 'build', 'msw', 'makefile.vc') do_bakefile = False if force_bakefile: inform('forcing bakefile_gen') do_bakefile = True elif not isfile(msw_makefile): inform('makefile.vc missing, running bakefile') do_bakefile = True if do_bakefile: bakefile() assert isfile( msw_makefile ), "running bakefile_gen did not create %s" % msw_makefile make_cmd = ['nmake', '-f', 'makefile.vc'] + stropts(WX_MAKEFILE_ARGS) # build WX main libraries with cd(WXDIR, 'build', 'msw'): run(make_cmd) # build contribs if CONTRIB['STC']: with cd(WXDIR, 'contrib', 'build', 'stc'): run(make_cmd) inform('wxWidgets built successfully in %s' % abspath(WXDIR)) # install from buildutil import copy_different, DEPS_DIR bindir = pathjoin(abspath(WXDIR), 'lib', 'vc_dll') for dll in ('base28%s_net_vc base28%s_vc msw28%s_adv_vc ' 'msw28%s_core_vc msw28%s_stc_vc').split(): dll = dll % ('u' + WX_MAKEFILE_ARGS['WXDEBUGFLAG']) for ext in ('.dll', '.pdb'): src, dest = pathjoin(bindir, 'wx' + dll + ext), DEPS_DIR copy_different(src, dest)
def build_jpeg(): with cd(jpeg.get()): # setup for nmake build shutil.copy2('jconfig.vc', 'jconfig.h') # make sure libjpeg is built against the multithreaded C runtime # library. run(['nmake', '-f', 'makefile.vc', 'NODEBUG=' + ('0' if DEBUG else '1')]) lib = abspath('libjpeg.lib') assert exists(lib) return lib
def check_swig(): 'Checks for the correct version of SWIG.' try: run(['swig', '-version'], checkret=False) except Exception: fatal(SWIG_MSG) if not 'SWIG_LIB' in os.environ: fatal("ERROR: no SWIG_LIB\n" "please set SWIG_LIB in your environment to the Lib folder " "underneath Swig's installation folder")
def build(force_bakefile = False): abs_wxdir = abspath(WXDIR) os.environ.update( WXWIN = abspath(WXDIR), WXDIR = abspath(WXDIR), #CAIRO_ROOT = abspath(pathjoin(WXDIR, 'external', 'cairo-dev')), ) copy_setup_h() check_bakefile() msw_makefile = pathjoin(WXDIR, 'build', 'msw', 'makefile.vc') do_bakefile = False if force_bakefile: inform('forcing bakefile_gen') do_bakefile = True elif not isfile(msw_makefile): inform('makefile.vc missing, running bakefile') do_bakefile = True if do_bakefile: bakefile() assert isfile(msw_makefile), "running bakefile_gen did not create %s" % msw_makefile make_cmd = ['nmake', '-f', 'makefile.vc'] + stropts(WX_MAKEFILE_ARGS) # build WX main libraries with cd(WXDIR, 'build', 'msw'): run(make_cmd) # build contribs if CONTRIB['STC']: with cd(WXDIR, 'contrib', 'build', 'stc'): run(make_cmd) inform('wxWidgets built successfully in %s' % abspath(WXDIR)) # install from buildutil import copy_different, DEPS_DIR bindir = pathjoin(abspath(WXDIR), 'lib', 'vc_dll') for dll in ('base28%s_net_vc base28%s_vc msw28%s_adv_vc ' 'msw28%s_core_vc msw28%s_stc_vc').split(): dll = dll % ('u' + WX_MAKEFILE_ARGS['WXDEBUGFLAG']) for ext in ('.dll', '.pdb'): src, dest = pathjoin(bindir, 'wx' + dll + ext), DEPS_DIR copy_different(src, dest)
def build(): with cd(thisdir): lzma_dir = lzma_sdk.get() if not isdir(ppmd7_dir): git.run(["clone", ppmd7_git_url]) assert isdir(ppmd7_dir) with cd(ppmd7_dir): libname = "ppmd7" config = "Release" if not DEBUG else "Debug" run(["vcbuild", "libppmd7.sln", "%s|Win32" % config]) for ext in (".dll", ".pdb"): copy_different(os.path.join(config, libname + ext), DEPS_DIR)
def build(): with cd(thisdir): lzma_dir = lzma_sdk.get() if not isdir(ppmd7_dir): git.run(['clone', ppmd7_git_url]) assert isdir(ppmd7_dir) with cd(ppmd7_dir): libname = 'ppmd7' config = 'Release' if not DEBUG else 'Debug' run(['vcbuild', 'libppmd7.sln', '%s|Win32' % config]) for ext in ('.dll', '.pdb'): copy_different(os.path.join(config, libname + ext), DEPS_DIR)
def build_jpeg(): with cd(jpeg.get()): # setup for nmake build shutil.copy2('jconfig.vc', 'jconfig.h') # make sure libjpeg is built against the multithreaded C runtime # library. run([ 'nmake', '-f', 'makefile.vc', 'NODEBUG=' + ('0' if DEBUG else '1') ]) lib = abspath('libjpeg.lib') assert exists(lib) return lib
def build(): # output the version of mt.exe--should be > 6 # run('mt /', checkret = False) 'Builds and deploys executables and debugging symbol files.' with cd(UPDATER_PROJECT_DIR): # remove the old Release directory run(['cmd', '/c', 'rmdir', '/s', '/q', 'Release'], checkret = False) # invoke MSVC2008 print run(['devenv', '/build', 'release', UPDATER_SOLUTION], checkret = False) bindir = UPDATER_PROJECT_DIR / 'Release' if not (bindir / 'Digsby PreUpdater.exe').isfile(): raise Exception('Visual Studio did not build the executables')
def build(): # output the version of mt.exe--should be > 6 # run('mt /', checkret = False) 'Builds and deploys executables and debugging symbol files.' with cd(UPDATER_PROJECT_DIR): # remove the old Release directory run(['cmd', '/c', 'rmdir', '/s', '/q', 'Release'], checkret=False) # invoke MSVC2008 print run(['devenv', '/build', 'release', UPDATER_SOLUTION], checkret=False) bindir = UPDATER_PROJECT_DIR / 'Release' if not (bindir / 'Digsby PreUpdater.exe').isfile(): raise Exception('Visual Studio did not build the executables')
def check_tools(): # perl - required for _ssl module try: run(['perl', '--version']) except Exception: fatal('Missing perl!\nPlease install ActiveState Perl from ' 'http://www.activestate.com/Products/activeperl/') # nasm - required for _ssl module try: run(['nasmw', '-version']) except Exception: fatal('Missing NASM.\nPlease place binaries from ' 'http://www.nasm.us/ ' 'on your PATH. (copy nasm.exe to nasmw.exe)')
def _check(): stdout = buildutil.run(['xgettext'], expect_return_code=1, capture_stdout=True, include_stderr=True) if not 'no input file given' in stdout: raise Exception('unexpected output')
def build_curl(): # relies on openssl-0.9.8g being in msw/ (should be there from # building Python) new = not os.path.exists(curl.dirname) with cd(curl.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by curl_patch. # see the note above for an explanation. run([patch_cmd, '-p0', '-i', '../' + curl_patch]) filerepl('lib/Makefile.vc6', '/O2 /DNDEBUG', '/Zi /Ox /GL /GS- /GR- /DNDEBUG') filerepl('lib/Makefile.vc6', 'LFLAGS = /nologo /machine:$(MACHINE)', 'LFLAGS = /DEBUG /nologo /machine:$(MACHINE)') openssl_includes = "../../../../../digsby-venv" # point at includes filerepl( 'lib/Makefile.vc6', '/DUSE_SSLEAY /I "$(OPENSSL_PATH)/inc32"', '/DUSE_SSLEAY /I "%s/PC" /I "%s/PC/openssl" /I "$(OPENSSL_PATH)/inc32"' % (openssl_includes, openssl_includes)) # point at .libs filerepl('lib/Makefile.vc6', 'LFLAGSSSL = "/LIBPATH:$(OPENSSL_PATH)\out32dll"', 'LFLAGSSSL = "/LIBPATH:%s/libs"' % openssl_includes) with cd('lib'): run([ 'nmake', '/nologo', '/E', '/f', 'Makefile.vc6', 'cfg=%s-dll-ssl-dll-zlib-dll' % ('debug' if DEBUG else 'release'), 'ZLIBLIBSDLL=zlib1%s.lib' % ('d' if DEBUG else ''), 'IMPLIB_NAME=libcurl', 'IMPLIB_NAME_DEBUG=libcurld' ]) # copy libcurl.dll to digsby/build/msw/dependencies from buildutil import copy_different, DEPS_DIR copy_different('libcurl%s.dll' % curl_pfix, DEPS_DIR) copy_different('libcurl%s.pdb' % curl_pfix, DEPS_DIR)
def build_curl(): # relies on openssl-0.9.8g being in msw/ (should be there from # building Python) new = not os.path.exists(curl.dirname) with cd(curl.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by curl_patch. # see the note above for an explanation. run([patch_cmd, '-p0', '-i', '../' + curl_patch]) filerepl('lib/Makefile.vc6', '/O2 /DNDEBUG', '/Zi /Ox /GL /GS- /GR- /DNDEBUG') filerepl('lib/Makefile.vc6', 'LFLAGS = /nologo /machine:$(MACHINE)', 'LFLAGS = /DEBUG /nologo /machine:$(MACHINE)') openssl_includes = "../../../../../digsby-venv" # point at includes filerepl('lib/Makefile.vc6', '/DUSE_SSLEAY /I "$(OPENSSL_PATH)/inc32"', '/DUSE_SSLEAY /I "%s/PC" /I "%s/PC/openssl" /I "$(OPENSSL_PATH)/inc32"' % (openssl_includes, openssl_includes)) # point at .libs filerepl('lib/Makefile.vc6', 'LFLAGSSSL = "/LIBPATH:$(OPENSSL_PATH)\out32dll"', 'LFLAGSSSL = "/LIBPATH:%s/libs"' % openssl_includes) with cd('lib'): run(['nmake', '/nologo', '/E', '/f', 'Makefile.vc6', 'cfg=%s-dll-ssl-dll-zlib-dll' % ('debug' if DEBUG else 'release'), 'ZLIBLIBSDLL=zlib1%s.lib' % ('d' if DEBUG else ''), 'IMPLIB_NAME=libcurl', 'IMPLIB_NAME_DEBUG=libcurld'] ) # copy libcurl.dll to digsby/build/msw/dependencies from buildutil import copy_different, DEPS_DIR copy_different('libcurl%s.dll' % curl_pfix, DEPS_DIR) copy_different('libcurl%s.pdb' % curl_pfix, DEPS_DIR)
def sip(): sip_path_parent, sip_dir = os.path.split(os.path.abspath(sip_path)) # Get SIP needs_build = True with cd(sip_path_parent): if not isdir(sip_dir): inform('Could not find SIP directory at %r, downloading...' % sip_path) git.run(['clone', SIP_GIT_REPO, sip_dir]) if SIP_GIT_BRANCH != 'master': with cd(sip_dir): git.run(['checkout', '-b', SIP_GIT_BRANCH, SIP_GIT_REMOTE + '/' + SIP_GIT_BRANCH]) else: pass # inform('SIP found at %r, updating...' % sip_path) # with cd(sip_dir): # git.run(['pull']) # if not git.sha_changed() and isfile(sip_exe) and isfile(sip_pyd): # inform('skipping SIP build') # needs_build = False # Build SIP if needs_build and 'nosip' not in sys.argv: with cd(sip_path): if not sys.platform.startswith("win"): dpy(['configure.py', '-b', 'sipgen', '-d', 'siplib', '-e', 'siplib', '-v', 'siplib']) # sip sets CC and CXX directly to cc and c++ rather than pulling the values # from the environment, which we don't want if we're forcing a 32-bit build # by using gcc 4.0. env = os.environ run(['make', 'CC=%s' % env['CC'], 'CXX=%s' % env['CXX'], 'LINK=%s' % env['CXX']]) else: dpy(['setup.py', 'build']) assert isfile(sip_exe), "setup.py did not create %s" % sip_exe if sys.platform.startswith("win"): from buildutil import copy_different, DEPS_DIR copy_different(sip_pyd, DEPS_DIR) copy_different(sip_pdb, DEPS_DIR)
def build_zlib(): copy_different('../../../builddeps/msvc2008/' + zlib.filename, '.') unzip(zlib.filename) with cd('zlib-1.2.3'): lib_dest_path = os.getcwd() with cd('projects/visualc9-x86'): configname = 'DLL ASM %s' % ('Debug' if DEBUG else 'Release') run(['vcbuild', 'zlib.vcproj', configname]) # install the ZLIB dll and pdb print 'DEPS_DIR here', DEPS_DIR with cd('Win32/' + configname): debug_flag = 'd' if DEBUG else '' for dest in (DEPS_DIR, lib_dest_path): copy_different('zlib1%s.dll' % debug_flag, dest) copy_different('zlib1%s.pdb' % debug_flag, dest) copy_different('zlib1%s.lib' % debug_flag, dest)
def build_lxml(): from compiledeps import libxml2_dirname libxml2_dir = abspath(libxml2_dirname) iconv_dir = abspath(iconv_dirname) lxml2_libs = pathjoin(libxml2_dir, 'win32', 'bin.msvc') if not isdir(lxml2_libs): fatal('could not find libxml2.lib in %s' % lxml2_libs) lxml2_inc = pathjoin(libxml2_dir, 'include') if not isdir(lxml2_inc): fatal('could not find libxml2 includes directory at %s' % lxml2_inc) if not isdir(iconv_dir): fatal('could not find iconv at %s' % iconv_dir) libxslt_dir = abspath(libxslt.dirname) if not isdir(libxslt_dir): fatal('could not find libxslt at %s' % libxslt_dir) libxslt_lib = pathjoin(libxslt_dir, 'win32', 'bin.msvc') zlib_dir = abspath('zlib-1.2.3') from compiledeps import lxml new = not os.path.exists(lxml.dirname) with cd(lxml.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by lxml_patch. run([ patch_cmd, '--ignore-whitespace', '-p0', '-i', '../%s' % lxml_patch ]) dpy([ 'setup.py', 'build_ext', '-I' + os.pathsep.join( (lxml2_inc, libxslt_dir, pathjoin(iconv_dir, 'include'))), '-L' + os.pathsep.join((libxslt_lib, lxml2_libs, pathjoin(iconv_dir, 'lib'), zlib_dir)) ] + (['--debug'] if DEBUG else []) + ['install', '--install-lib', DEPS_DIR]) build_libxml2
def install_stdlib(): 'Copies all the .py files in python/Lib' from buildutil import copy_different with cd(PYTHON_DIR): exclude = '.xcopy.exclude' # have to specify xcopy excludes in a file with open(exclude, 'w') as fout: fout.write('\n'.join(['.pyc', '.pyo', '.svn'])) try: run(['xcopy', 'Lib', r'%s\lib' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I','/E','/D','/Y']) run(['xcopy', 'Include', r'%s\Include' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I','/E','/D','/Y']) if not os.path.isdir(r'%s\libs' % DPYTHON_DIR): os.makedirs(r'%s\libs' % DPYTHON_DIR) for f in os.listdir(r'PCBuild'): if f.endswith('.lib'): copy_different(os.path.join('PCBuild', f), os.path.join(r'%s\libs' % DPYTHON_DIR, f)) finally: os.remove(exclude)
def test(): # check that python is there print print 'using python', PYTHON_EXE print 'current working directory is', os.getcwd() print try: run([PYTHON_EXE, '-c', 'import sys; sys.exit(0)']) except Exception: print_exc() fatal('Error building Python executable') # check that we can import ssl try: run([PYTHON_EXE, '-c', 'import socket; socket.ssl; import sys; sys.exit(0)']) except Exception: fatal('error building SSL module') inform('\nPython built successfully!')
def clean(): with cd(PYTHON_DIR, PCBUILD_DIR): config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run(['devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config, '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config], checkret = False) else: run(['vcbuild', 'pcbuild.sln', '/clean', '%s|Win32' % config], checkret = False)
def __call__(self, parser, ns, value, option_string): if not value: return print 'running Po', id(self) with buildutil.cd(DIGSBYROOT): default_pot = TEMP_path('digsby_default.pot') sip_pot = TEMP_path('digsby_sip.pot') yaml_pot = TEMP_path('digsby_yaml.pot') tenjin_pot = TEMP_path('digsby_tenjin.pot') input_pots = [default_pot, sip_pot, yaml_pot, tenjin_pot] final_pot = POT_path('digsby') for pot in input_pots: if os.path.isfile(pot): os.remove(pot) xgettext(FIL_PATH, default_pot) # xgettext(FIL_SIP_PATH, sip_pot, '-C') xgettext_yaml(FIL_YAML_PATH, yaml_pot) xgettext(FIL_TENJIN_PATH, tenjin_pot, '-L', 'python') input_pots = filter(lambda pot: os.path.isfile(pot), input_pots) cat = pot_read_clean(input_pots[0]) for potfile in input_pots[1:]: cat_u = pot_read_clean(potfile) for msg in cat_u: cat[msg.id] = msg write_pot(final_pot, cat, version=True) pofiles = [ os.path.join(PO_DIR, f) for f in os.listdir(PO_DIR) if f.endswith('.po') ] for pofile in pofiles: buildutil.run([ 'msgmerge', '-F', '--no-wrap', pofile, final_pot, '-o', pofile ])
def test(): # check that python is there print print 'using python', PYTHON_EXE print 'current working directory is', os.getcwd() print try: run([PYTHON_EXE, '-c', 'import sys; sys.exit(0)']) except Exception: print_exc() fatal('Error building Python executable') # check that we can import ssl try: run([ PYTHON_EXE, '-c', 'import socket; socket.ssl; import sys; sys.exit(0)' ]) except Exception: fatal('error building SSL module') inform('\nPython built successfully!')
def build_lxml(): from compiledeps import libxml2_dirname libxml2_dir = abspath(libxml2_dirname) iconv_dir = abspath(iconv_dirname) lxml2_libs = pathjoin(libxml2_dir, 'win32', 'bin.msvc') if not isdir(lxml2_libs): fatal('could not find libxml2.lib in %s' % lxml2_libs) lxml2_inc = pathjoin(libxml2_dir, 'include') if not isdir(lxml2_inc): fatal('could not find libxml2 includes directory at %s' % lxml2_inc) if not isdir(iconv_dir): fatal('could not find iconv at %s' % iconv_dir) libxslt_dir = abspath(libxslt.dirname) if not isdir(libxslt_dir): fatal('could not find libxslt at %s' % libxslt_dir) libxslt_lib = pathjoin(libxslt_dir, 'win32', 'bin.msvc') zlib_dir = abspath('zlib-1.2.3') from compiledeps import lxml new = not os.path.exists(lxml.dirname) with cd(lxml.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by lxml_patch. run([patch_cmd, '--ignore-whitespace', '-p0', '-i', '../%s' % lxml_patch]) dpy(['setup.py', 'build_ext', '-I' + os.pathsep.join((lxml2_inc, libxslt_dir, pathjoin(iconv_dir, 'include'))), '-L' + os.pathsep.join((libxslt_lib, lxml2_libs, pathjoin(iconv_dir, 'lib'), zlib_dir))] + (['--debug'] if DEBUG else []) + ['install', '--install-lib', DEPS_DIR]) build_libxml2
def checkout(): 'Checks out Python source.' run(['svn', 'co', PYTHON_SVN_URL, PYTHON_DIR]) patch_cmd = get_patch_cmd() def banner_msg(s): print print s print def apply_patch(patchfile, strip_prefixes=0): assert os.path.isfile(patchfile) run([patch_cmd, '-p%d' % strip_prefixes, '-i', patchfile]) with cd(PYTHON_DIR): if sys.opts.use_computed_goto: banner_msg('applying computed goto patch') apply_patch('../python26-computed-goto.patch') banner_msg('applying assert mode patch') # this patch restores c assert()s and is made with # svn diff http://svn.python.org/projects/python/trunk@69494 http://svn.python.org/projects/python/trunk@69495 apply_patch('../python26-assert-mode.patch') banner_msg('applying file object close bug patch') # http://bugs.python.org/issue7079 -- remove once we update to a newer version of 2.6 apply_patch('../python26-file-object-close-7079.patch') if USE_DEVENV and sys.opts.intel: banner_msg('applying intel project patch') apply_patch('../vs2008+intel.patch', 3) banner_msg('applying common controls patch') apply_patch('../python-common-controls.patch')
def get_deps(): ''' Gets external dependencies needed to build Python. (From http://svn.python.org/view/python/branches/release25-maint/Tools/buildbot/external.bat?rev=51340&view=markup) intentionally missing: - tcl/tk - Sleepycat db ''' import shutil bzip_dir, bzip_checkout = PYTHON_BZIP if not exists(bzip_dir): run(['svn', 'export', bzip_checkout]) else: inform(bzip_dir + ': already exists') sqlite_dir, sqlite_checkout = PYTHON_SQLITE if not exists(sqlite_dir): run(['svn', 'export', sqlite_checkout]) else: inform(bzip_dir + ': already exists') makefile = os.path.join(bzip_dir, 'makefile.msc') debug_makefile = os.path.join(bzip_dir, 'makefile.debug.msc') release_makefile = os.path.join(bzip_dir, 'makefile.release.msc') if not os.path.isfile(debug_makefile): shutil.copy2(makefile, release_makefile) with open(makefile, 'r') as f: lines = f.readlines() with open(debug_makefile, 'w') as f: for line in lines: if line.strip() == 'CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo': line = 'CFLAGS= -DWIN32 -MDd -Od -D_FILE_OFFSET_BITS=64 -nologo -Zi\n' f.write(line) assert os.path.isfile(release_makefile) assert os.path.isfile(debug_makefile) src = release_makefile if not DEBUG else debug_makefile dest = makefile shutil.copy2(src, dest) if not exists('openssl-0.9.8g'): run(['svn', 'export', 'http://svn.python.org/projects/external/openssl-0.9.8g']) else: inform('openssl-0.9.8g: already exists') os.environ['PATH'] = os.pathsep.join([os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(__file__), 'openssl-0.9.8g'))), os.environ['PATH']])
def build(): check_tools() with cd(PYTHON_DIR, PCBUILD_DIR): # fix up files for SSL stuff fix_build_ssl_py() config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run(['devenv', 'pcbuild.sln', '/build', "%s|Win32" % config, '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/build', "%s|Win32" % config], checkret = False) else: run(['vcbuild', 'pcbuild.sln', '%s|Win32' % config], checkret = False)
def clean(): with cd(PYTHON_DIR, PCBUILD_DIR): config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run([ 'devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config, '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config], checkret=False) else: run(['vcbuild', 'pcbuild.sln', '/clean', '%s|Win32' % config], checkret=False)
def build(): check_tools() with cd(PYTHON_DIR, PCBUILD_DIR): # fix up files for SSL stuff fix_build_ssl_py() config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run([ 'devenv', 'pcbuild.sln', '/build', "%s|Win32" % config, '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/build', "%s|Win32" % config], checkret=False) else: run(['vcbuild', 'pcbuild.sln', '%s|Win32' % config], checkret=False)
def build_libxml2(): from compiledeps import libxml2_dirname new = not os.path.exists(libxml2_dirname) libxml2_dir = download_libxml2() with cd(libxml2_dir): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by lxml_patch. print os.getcwd() run([ patch_cmd, '--ignore-whitespace', '-p0', '-i', os.path.abspath(os.path.join('..', libxml2_patch)) ]) inform(banner='libiconv') if not isdir(iconv_dirname): # has a .lib compiled statically to msvcrt.dll wget_cached(iconv_zipfile, iconv_zipfile_size, iconv_url) unzip(iconv_zipfile) else: inform('libiconv directory already exists') patch_libxml2_h(libxml2_dir, 'include') iconv = abspath(iconv_dirname) inform(banner='libxml2') print 'passing libiconv path to configure.js as %r' % iconv # copy the fixed setup.py.in print 'copying libxml2.setup.py.msvc2008', pathjoin(libxml2_dir, 'python') patched_setup = 'libxml2.setup.py.msvc2008' assert os.path.exists(patched_setup) copy_different(patched_setup, pathjoin(libxml2_dir, 'python', 'setup.py.in')) with cd(libxml2_dir, 'win32'): debug_flag = ['debug=yes'] if DEBUG else [] run([ 'cscript', 'configure.js', '//E:JavaScript', 'vcmanifest=yes', 'python=yes' ] + debug_flag + [ 'include=%s' % pathjoin(iconv, 'include'), 'lib=%s' % pathjoin(iconv, 'lib') ]) makefile = 'Makefile.msvc' # customize the Makefile... with open(makefile) as f: lines = [] for line in f: # 1) optimize a bit more than just /O2 line = line.replace('/O2', '/Os /GS- /GL /Zi') line = line.replace( '/nologo /VERSION', '/nologo /OPT:REF /OPT:ICF /DEBUG /VERSION') lines.append(line) with open(makefile, 'w') as f: f.write(''.join(lines)) with cd(libxml2_dir, 'win32'): run(['nmake', '-f', makefile] + (['clean'] if CLEAN else [])) # All finished files go to DEPS_DIR: mkdirs(DEPS_DIR) deps = os.path.abspath(DEPS_DIR) inform(banner='libxml2 python bindings') with cd(libxml2_dir, 'python'): # installs libxml2 python files to deps directory' #post commit hook test line, git failed to catch the last one. dpy(['setup.py', 'build_ext'] + (['--debug'] if DEBUG else []) + ['install', '--install-lib', deps]) # but we still need libxml2.dll libxml2_bindir = pathjoin(libxml2_dir, 'win32', 'bin.msvc') copy_different(pathjoin(libxml2_bindir, 'libxml2.dll'), deps) copy_different(pathjoin(libxml2_bindir, 'libxml2.pdb'), deps) # and iconv.dll copy_different(os.path.join(iconv, 'iconv.dll'), deps) # show which Python was used to build the PYD dpy([ '-c', "import sys; print 'libxml2 python bindings built with %s' % sys.executable" ]) with cd(DEPS_DIR): dpy(['-c', "import libxml2"]) # build and install libxslt libxslt_dir = build_libxslt() copy_different( os.path.join(libxslt_dir, 'win32', 'bin.msvc', 'libxslt.dll'), deps) copy_different( os.path.join(libxslt_dir, 'win32', 'bin.msvc', 'libexslt.dll'), deps)
def get_deps(): ''' Gets external dependencies needed to build Python. (From http://svn.python.org/view/python/branches/release25-maint/Tools/buildbot/external.bat?rev=51340&view=markup) intentionally missing: - tcl/tk - Sleepycat db ''' import shutil bzip_dir, bzip_checkout = PYTHON_BZIP if not exists(bzip_dir): run(['svn', 'export', bzip_checkout]) else: inform(bzip_dir + ': already exists') sqlite_dir, sqlite_checkout = PYTHON_SQLITE if not exists(sqlite_dir): run(['svn', 'export', sqlite_checkout]) else: inform(bzip_dir + ': already exists') makefile = os.path.join(bzip_dir, 'makefile.msc') debug_makefile = os.path.join(bzip_dir, 'makefile.debug.msc') release_makefile = os.path.join(bzip_dir, 'makefile.release.msc') if not os.path.isfile(debug_makefile): shutil.copy2(makefile, release_makefile) with open(makefile, 'r') as f: lines = f.readlines() with open(debug_makefile, 'w') as f: for line in lines: if line.strip( ) == 'CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo': line = 'CFLAGS= -DWIN32 -MDd -Od -D_FILE_OFFSET_BITS=64 -nologo -Zi\n' f.write(line) assert os.path.isfile(release_makefile) assert os.path.isfile(debug_makefile) src = release_makefile if not DEBUG else debug_makefile dest = makefile shutil.copy2(src, dest) if not exists('openssl-0.9.8g'): run([ 'svn', 'export', 'http://svn.python.org/projects/external/openssl-0.9.8g' ]) else: inform('openssl-0.9.8g: already exists') os.environ['PATH'] = os.pathsep.join([ os.path.normpath( os.path.abspath( os.path.join(os.path.dirname(__file__), 'openssl-0.9.8g'))), os.environ['PATH'] ])
def bakefile(): with cd(WXDIR, 'build', 'bakefiles'): run(['bakefile_gen', '-f', 'msvc'])
def run(cmd): buildutil.run(GIT_BIN + cmd)
def rmdir(p): p = os.path.abspath(p) if os.path.isdir(p): run(['cmd', '/c', 'rmdir', '/s', '/q', p], checkret=False)
def apply_patch(patchfile, strip_prefixes=0): assert os.path.isfile(patchfile) run([patch_cmd, '-p%d' % strip_prefixes, '-i', patchfile])
def cygwin(cmd, env=None): run([CYGWIN_PATH + '\\bin\\bash', '--login', '-c', cmd], env=env)
def bench(pgo = None): if pgo is None: pgo = getattr(getattr(sys, 'opts', None), 'pgo', None) if not DEBUG and pgo: with cd(PYTHON_DIR): run([PYTHON_EXE, 'Tools/pybench/pybench.py', '-f', '26.bench.txt']) with cd(PCBUILD_DIR): run(['devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32", '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32"], checkret = False) run([PYTHON_EXE_PGI, 'Tools/pybench/pybench.py', '-f', '26pgi.bench.txt']) with cd(PCBUILD_DIR): run(['devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32", '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32"], checkret = False) run([PYTHON_EXE_PGO, 'Tools/pybench/pybench.py', '-f', '26pgo.bench.txt'])
def svn_version(path = '.'): 'Returns the current revision for a given working copy directory.' v = run(['svnversion', '.'], capture_stdout = True) if v.endswith('M'): v = v[:-1] return int(v)
def svn_version(path='.'): 'Returns the current revision for a given working copy directory.' v = run(['svnversion', '.'], capture_stdout=True) if v.endswith('M'): v = v[:-1] return int(v)
def bench(pgo=None): if pgo is None: pgo = getattr(getattr(sys, 'opts', None), 'pgo', None) if not DEBUG and pgo: with cd(PYTHON_DIR): run([PYTHON_EXE, 'Tools/pybench/pybench.py', '-f', '26.bench.txt']) with cd(PCBUILD_DIR): run([ 'devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32", '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32"], checkret=False) run([ PYTHON_EXE_PGI, 'Tools/pybench/pybench.py', '-f', '26pgi.bench.txt' ]) with cd(PCBUILD_DIR): run([ 'devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32", '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32"], checkret=False) run([ PYTHON_EXE_PGO, 'Tools/pybench/pybench.py', '-f', '26pgo.bench.txt' ])