Exemple #1
0
def copy_setup_h():
    inform('copying include/wx/msw/setup0.h to include/wx/msw/setup.h with modifications')

    with cd(WXDIR, 'include', 'wx', 'msw'):

        # setup0.h is the "template" for setup.h. we use the setup_h_use_flags
        # dictionary above to set certain values in it for things we want to
        # customize (results in smaller binaries, since about 50% of wx we don't
        # use or need)
        f   = open('setup0.h', 'rU')
        out = open('setup.h', 'w')

        flags = dict(setup_h_use_flags)
        define_use = '#define wxUSE_'
        for line in f:
            i = line.find(define_use)
            if i != -1:
                use_name = line[i+len(define_use):].split()[0]
                if use_name in flags:
                    line = '%s%s %s\n' % (define_use, use_name, flags.pop(use_name))

            out.write(line)

        # make sure there are no leftover flags
        if flags:
            leftover = '\n'.join('  wxUSE_%s' % key for key in flags.iterkeys())
            raise AssertionError('invalid wxUSE_XXX flags (were not found in setup0.h):\n%s' % leftover)

        out.close()
        f.close()
Exemple #2
0
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)
Exemple #3
0
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
Exemple #4
0
def install_wxpy():
    # install to dependencies dir
    from buildutil import DEPS_DIR
    install_dir = pathjoin(DEPS_DIR, 'wx')
    inform('\n\ninstalling wxpy to %s' % install_dir)

    def ffilter(f):
        return not any(map(f.endswith, ('.exp', '.idb', '.pyc', '.lib')))

    with cd(wxpy_path):
        copytree_filter('wx', install_dir, filefilter = ffilter, only_different = True)
Exemple #5
0
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
Exemple #6
0
def check_msvc():
    'Ensures that Microsoft Visual Studio 2008 paths are setup correctly.'

    try:
        devenvdir = os.environ['DevEnvDir']
    except KeyError:
        fatal('DevEnvDir environment variable not set -- did you start a Visual Studio 2008 Command Prompt?')

    if '9.0' not in devenvdir:
        fatal('error: not visual studio 2008')

    inform('Microsoft Visual Studio 2008 check: OK')
Exemple #7
0
def install_wxpy():
    # install to dependencies dir
    from buildutil import DEPS_DIR
    install_dir = pathjoin(DEPS_DIR, 'wx')
    inform('\n\ninstalling wxpy to %s' % install_dir)

    def ffilter(f):
        return not any(map(f.endswith, ('.exp', '.idb', '.pyc', '.lib')))

    with cd(wxpy_path):
        copytree_filter('wx',
                        install_dir,
                        filefilter=ffilter,
                        only_different=True)
Exemple #8
0
def wxpy(rebuild = False, branch="master"):
    wxpy_path_parent, wxpy_dir = os.path.split(os.path.abspath(wxpy_path))

    # must have wx and webkit directories
    wx_dir = buildDirs.wxWidgetsDir
    webkit_dir = buildDirs.wxWebKitDir

    sip_dir = os.path.abspath(sip_path)

    with cd(wxpy_path_parent):
        if not isdir(wxpy_dir):
            inform('Could not find wxpy directory at %r, downloading...' % wxpy_path)
            git.run(['clone', WXPY_GIT_REPO, wxpy_dir])
            if branch != "master":
                with cd(wxpy_dir):
                    git.run(['checkout', '-b', branch, 'origin/%s' % branch])

        # else:
        #     with cd(wxpy_dir):
        #         git.run(['pull'])

        # wipe out the "wxpy/build" directory if we're rebuilding

        if rebuild:
            inform("rebuilding...removing old build directory")
            with cd(wxpy_dir):
                if os.path.isdir('build'):
                    shutil.rmtree('build')

        sip_pyd_loc = pathjoin(sip_dir, 'siplib')

        sip_exe = 'sip%s.%s' % (DEBUG_POSTFIX, py_ext)
        assert os.path.isfile(pathjoin(sip_pyd_loc, sip_exe)), \
            "could not find %s at %r" % (sip_exe, sip_pyd_loc)
        pp = os.pathsep.join([sip_dir, sip_pyd_loc])

        os.environ['PYTHONPATH'] = pp

        print 'PYTHONPATH=' +  pp

        with cd(wxpy_dir):
            dpy(['setup.py',
                 '--wx=%s' % wx_dir,
                 '--webkit=%s' % webkit_dir]
                + sys.argv[1:])


    install_wxpy()
Exemple #9
0
def wxpy(rebuild=False, branch="master"):
    wxpy_path_parent, wxpy_dir = os.path.split(os.path.abspath(wxpy_path))

    # must have wx and webkit directories
    wx_dir = buildDirs.wxWidgetsDir
    webkit_dir = buildDirs.wxWebKitDir

    sip_dir = os.path.abspath(sip_path)

    with cd(wxpy_path_parent):
        if not isdir(wxpy_dir):
            inform('Could not find wxpy directory at %r, downloading...' %
                   wxpy_path)
            git.run(['clone', WXPY_GIT_REPO, wxpy_dir])
            if branch != "master":
                with cd(wxpy_dir):
                    git.run(['checkout', '-b', branch, 'origin/%s' % branch])

        # else:
        #     with cd(wxpy_dir):
        #         git.run(['pull'])

        # wipe out the "wxpy/build" directory if we're rebuilding

        if rebuild:
            inform("rebuilding...removing old build directory")
            with cd(wxpy_dir):
                if os.path.isdir('build'):
                    shutil.rmtree('build')

        sip_pyd_loc = pathjoin(sip_dir, 'siplib')

        sip_exe = 'sip%s.%s' % (DEBUG_POSTFIX, py_ext)
        assert os.path.isfile(pathjoin(sip_pyd_loc, sip_exe)), \
            "could not find %s at %r" % (sip_exe, sip_pyd_loc)
        pp = os.pathsep.join([sip_dir, sip_pyd_loc])

        os.environ['PYTHONPATH'] = pp

        print 'PYTHONPATH=' + pp

        with cd(wxpy_dir):
            dpy(['setup.py',
                 '--wx=%s' % wx_dir,
                 '--webkit=%s' % webkit_dir] + sys.argv[1:])

    install_wxpy()
Exemple #10
0
def get_wxdir():
    "WebKit's build scripts need a WXWIN environment variable to find wxWidgets."

    from build_wx import WXDIR
    WXDIR = abspath(WXDIR)
    return WXDIR

    if 'WXWIN' in environ:
        # already set in the enviornment
        inform('WXWIN is %s' % environ['WXWIN'])
        return environ
    else:
        # wasn't already set--use the path set in build_wx.py
        from build_wx import WXDIR
        WXDIR = abspath(WXDIR)
        inform('setting environment variable WXWIN=%s' % WXDIR)
        environ['WXWIN'] = WXDIR
Exemple #11
0
def get_wxdir():
    "WebKit's build scripts need a WXWIN environment variable to find wxWidgets."

    from build_wx import WXDIR
    WXDIR = abspath(WXDIR)
    return WXDIR

    if 'WXWIN' in environ:
        # already set in the enviornment
        inform('WXWIN is %s' % environ['WXWIN'])
        return environ
    else:
        # wasn't already set--use the path set in build_wx.py
        from build_wx import WXDIR
        WXDIR = abspath(WXDIR)
        inform('setting environment variable WXWIN=%s' % WXDIR)
        environ['WXWIN'] = WXDIR
Exemple #12
0
def checkout():
    if exists(WXDIR):
        inform('already exists: %s' % WXDIR)
    else:
        #inform('checking out wxWebKitBranch-2.8...')
        #run(['svn', 'checkout', WXWIDGETS_28_SVN_DIR, WXDIR])

        inform('cloning wxWebKitBranch-2.8')
        git.run(['clone', WX_GIT_REPO, abspath(WXDIR).replace('\\', '/'), '--depth=1'])
        with cd(WXDIR):
            # don't change newlines
            git.run(['config', 'core.autocrlf', 'false'])

            if WX_GIT_BRANCH != 'master':
                git.run(['fetch', 'origin'])
                # checkout our branch.
                git.run(['checkout', '-b', WX_GIT_BRANCH, 'origin/%s' % WX_GIT_BRANCH])
        assert exists(WXDIR)
Exemple #13
0
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)
Exemple #14
0
def checkout():
    if isdir(WEBKITDIR):
        inform('skipping checkout, %s already exists' % WEBKITDIR)
    else:
        inform('cloning WebKit')

        makedirs(WEBKITDIR)
        with cd(WEBKITDIR):
            git.run(['init'])

            # turn off auto CRLF conversion, so that cygwin bash
            # doesn't complain about line endings
            git.run(['config', 'core.autocrlf', 'false'])

            # Add our remote source
            git.run(['remote', 'add', WEBKIT_GIT_REMOTE, WEBKIT_GIT_REPO])
            git.run(['fetch', WEBKIT_GIT_REMOTE, '--depth', '1'])

            # checkout a local tracking branch of the remote branch we're interested in
            with timed():
                git.run(['checkout', '-b', WEBKIT_GIT_BRANCH, WEBKIT_GIT_REMOTE + '/' + WEBKIT_GIT_BRANCH])
Exemple #15
0
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!')
Exemple #16
0
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!')
Exemple #17
0
def checkout():
    if isdir(WEBKITDIR):
        inform('skipping checkout, %s already exists' % WEBKITDIR)
    else:
        inform('cloning WebKit')

        makedirs(WEBKITDIR)
        with cd(WEBKITDIR):
            git.run(['init'])

            # turn off auto CRLF conversion, so that cygwin bash
            # doesn't complain about line endings
            git.run(['config', 'core.autocrlf', 'false'])

            # Add our remote source
            git.run(['remote', 'add', WEBKIT_GIT_REMOTE, WEBKIT_GIT_REPO])
            git.run(['fetch', WEBKIT_GIT_REMOTE, '--depth', '1'])

            # checkout a local tracking branch of the remote branch we're interested in
            with timed():
                git.run([
                    'checkout', '-b', WEBKIT_GIT_BRANCH,
                    WEBKIT_GIT_REMOTE + '/' + WEBKIT_GIT_BRANCH
                ])
Exemple #18
0
def checkout():
    if exists(WXDIR):
        inform('already exists: %s' % WXDIR)
    else:
        #inform('checking out wxWebKitBranch-2.8...')
        #run(['svn', 'checkout', WXWIDGETS_28_SVN_DIR, WXDIR])

        inform('cloning wxWebKitBranch-2.8')
        git.run([
            'clone', WX_GIT_REPO,
            abspath(WXDIR).replace('\\', '/'), '--depth=1'
        ])
        with cd(WXDIR):
            # don't change newlines
            git.run(['config', 'core.autocrlf', 'false'])

            if WX_GIT_BRANCH != 'master':
                git.run(['fetch', 'origin'])
                # checkout our branch.
                git.run([
                    'checkout', '-b', WX_GIT_BRANCH,
                    'origin/%s' % WX_GIT_BRANCH
                ])
        assert exists(WXDIR)
Exemple #19
0
def copy_setup_h():
    inform(
        'copying include/wx/msw/setup0.h to include/wx/msw/setup.h with modifications'
    )

    with cd(WXDIR, 'include', 'wx', 'msw'):

        # setup0.h is the "template" for setup.h. we use the setup_h_use_flags
        # dictionary above to set certain values in it for things we want to
        # customize (results in smaller binaries, since about 50% of wx we don't
        # use or need)
        f = open('setup0.h', 'rU')
        out = open('setup.h', 'w')

        flags = dict(setup_h_use_flags)
        define_use = '#define wxUSE_'
        for line in f:
            i = line.find(define_use)
            if i != -1:
                use_name = line[i + len(define_use):].split()[0]
                if use_name in flags:
                    line = '%s%s %s\n' % (define_use, use_name,
                                          flags.pop(use_name))

            out.write(line)

        # make sure there are no leftover flags
        if flags:
            leftover = '\n'.join('  wxUSE_%s' % key
                                 for key in flags.iterkeys())
            raise AssertionError(
                'invalid wxUSE_XXX flags (were not found in setup0.h):\n%s' %
                leftover)

        out.close()
        f.close()
Exemple #20
0
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']])
Exemple #21
0
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)
Exemple #22
0
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)
Exemple #23
0
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)
Exemple #24
0
def update():
    with cd(WXDIR):
        inform('updating wxWidgets...')
        #run(['svn', 'up'])
        git.run(['checkout', WX_GIT_BRANCH])
        git.run(['pull', 'origin', WX_GIT_BRANCH])
Exemple #25
0
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)
Exemple #26
0
def update():
    with cd(WXDIR):
        inform('updating wxWidgets...')
        #run(['svn', 'up'])
        git.run(['checkout', WX_GIT_BRANCH])
        git.run(['pull', 'origin', WX_GIT_BRANCH])
Exemple #27
0
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']
    ])