Esempio n. 1
0
    def build_syck():
        from buildutil import wget_cached, unzip
        with cd(DEPS_DIR):
            dbgpostfix = '_d' if DEBUG else ''
            zip = 'pysyck_msvc2008_%s%s.zip' % (sys.version[:3].replace(
                '.', ''), dbgpostfix)

            wget_cached(
                zip, 42443,
                'http://symbolsystem.nfshost.com/build/msvc2008/' + zip)
            unzip(zip)
Esempio n. 2
0
    def build_syck():
        banner('syck')

        if not isdir(syck_dirname):
            wget_cached(syck_tarball, syck_tarball_size, syck_url)
            untar(syck_tarball)

        with cd(syck_dirname):
            global sdkflags
            sdkflags_syck = ""
            if sys.platform.startswith('darwin'):
                sdkflags_syck = sdkflags
            makeflags = [
                "CFLAGS=%s" % sdkflags_syck,
                "LDFLAGS=%s -L%s/lib" % (sdkflags_syck, os.path.abspath('.'))
            ]

            run([
                './configure',
                '--prefix=%s' % DEPS_DIR,
                '--exec-prefix=%s' % DEPS_DIR
            ] + configureflags)
            run(['make'] + makeflags)
            run(['make', 'install'])

        banner('pysyck')

        if not isdir(pysyck_dirname):
            wget_cached(pysyck_tarball, pysyck_tarball_size, pysyck_url)
            untar(pysyck_tarball)

        with cd(pysyck_dirname):
            # write out a small .cfg file to tell PySyck's setup.py where to
            # find syck includes and libraries
            with open('setup.cfg', 'w') as setup_cfg:
                setup_cfg.write(pysyck_cfg)
            dpy(['setup.py', 'install', '--install-lib', DEPS_DIR])
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
def build_pil():
    banner('PIL')

    if not isdir(pil_dirname):
        wget_cached(pil_tarball, pil_tarball_size, pil_url)
        untar(pil_tarball)

    jpeg = libjpeg_dirname
    zlib = '/usr/lib'
    freetype = None

    if sys.platform == 'darwin':
        freetype = '/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6'
        if not isdir(libjpeg_dirname):
            wget_cached(libjpeg_tarball, libjpeg_size, libjpeg_url)
            untar(libjpeg_tarball)

            with cd(libjpeg_dirname):
                bindir = os.path.join(DEPS_DIR, "bin")
                if not os.path.exists(bindir):
                    os.makedirs(bindir)
                mandir = os.path.join(DEPS_DIR, "man", "man1")
                if not os.path.exists(mandir):
                    os.makedirs(mandir)
                run([
                    './configure',
                    '--prefix=%s' % DEPS_DIR,
                    '--exec-prefix=%s' % DEPS_DIR,
                ] + configureflags)
                run(['make'] + makeflags)
                run(['make', 'install'])

            jpeg = abspath(libjpeg_dirname)
        assert jpeg and isdir(jpeg)
    elif sys.platform == 'win32':
        jpeg = abspath(pathjoin('msw', 'jpeg-7'))
        zlib = abspath(pathjoin('msw', 'zlib-1.2.3'))
        freetype = build_freetype_msw()

        assert isdir(jpeg), jpeg
        assert isdir(zlib), zlib
        assert all(isdir(d) for d in freetype), freetype
    else:
        jpeg = None

    with cd(pil_dirname):
        if jpeg is not None:
            filerepl('setup.py', 'JPEG_ROOT = None', 'JPEG_ROOT = %r' % jpeg)
        if zlib is not None:
            filerepl(
                'setup.py',
                'elif sys.platform == "win32" and find_library_file(self, "zlib"):',
                'elif sys.platform == "win32" and find_library_file(self, "zlib1"):'
            )
            filerepl('setup.py',
                     '    feature.zlib = "zlib" # alternative name',
                     '    feature.zlib = "zlib1" # alternative name')
            filerepl('setup.py', 'ZLIB_ROOT = None', 'ZLIB_ROOT = %r' % zlib)
        if freetype is not None:
            if isinstance(freetype, type(())):
                filerepl('setup.py', 'FREETYPE_ROOT = None',
                         'FREETYPE_ROOT = %r' % (freetype, ))
            else:
                filerepl('setup.py', 'FREETYPE_ROOT = None',
                         'FREETYPE_ROOT = libinclude(%r)' % (freetype, ))

        dpy(['setup.py', 'clean'])

        debug_flag = ' --debug' if DEBUG else ''

        # TODO: is there a way to pass --debug to "build" other than through setup.cfg
        # and still have install work correctly?
        with open('setup.cfg', 'w') as f:
            f.write('[build]\ndebug=%d' % DEBUG)

        dpy([
            'setup.py', 'install', '--install-lib', DEPS_DIR,
            '--install-scripts', '.'
        ])
Esempio n. 6
0
def download_libxml2():
    if not isdir(libxml2_dirname):
        wget_cached(libxml2_tarball, libxml2_tarball_size, libxml2_url)
        untar(libxml2_tarball)
    return libxml2_dirname