예제 #1
0
파일: autoconf.py 프로젝트: sudodave/bypy
def main(args):
    simple_build()
    for path in walk(os.path.join(build_dir(), 'bin')):
        replace_in_file(path, build_dir(), PREFIX)
    for path in walk(build_dir()):
        if path.endswith('/autom4te.cfg'):
            replace_in_file(path, build_dir(), PREFIX)
예제 #2
0
def main(args):
    pyver = python_major_minor_version()
    b = build_dir()
    if ismacos:
        b = os.path.join(
            b, 'python/Python.framework/Versions/{}.{}'.format(*pyver))
    elif iswindows:
        b = os.path.join(b, 'private', 'python')
    cmd = [
        PYTHON, 'configure.py', '--no-pyi', '--sip-module=PyQt5.sip',
        '--bindir=%s/bin' % build_dir()
    ]
    sp = 'Lib' if iswindows else 'lib/python{}.{}'.format(*pyver)
    inc = 'include' if iswindows else 'include/python{}.{}'.format(*pyver)
    cmd += [
        '--destdir=%s/%s/site-packages' % (b, sp),
        '--sipdir=%s/share/sip' % b,
        '--incdir=%s/%s' % (b, inc)
    ]
    run(*cmd, library_path=True)
    if iswindows:
        run(f'"{NMAKE}"'), run(f'"{NMAKE}" install')
    else:
        run('make ' + MAKEOPTS)
        run('make install', library_path=True)
    q, r = build_dir(), PREFIX
    if iswindows:
        q = q.replace(os.sep, os.sep + os.sep)
        r = r.replace(os.sep, os.sep + os.sep)
    p = 'Lib' if iswindows else 'lib/python{}.{}'.format(*pyver)
    replace_in_file(os.path.join(b, p, 'site-packages/sipconfig.py'), q, r)
예제 #3
0
def unix_python2(args):
    env = {'CFLAGS': CFLAGS + ' -DHAVE_LOAD_EXTENSION'}
    replace_in_file('setup.py', re.compile(b'def detect_tkinter.+:'),
                    lambda m: m.group() + b'\n' + b' ' * 8 + b'return 0')
    conf = ('--prefix={} --with-threads --enable-ipv6 --enable-unicode={}'
            ' --with-system-expat --with-pymalloc --without-ensurepip').format(
                build_dir(), ('ucs2' if ismacos or iswindows else 'ucs4'))
    if islinux:
        conf += ' --with-system-ffi --enable-shared'
        # Needed as the system openssl is too old, causing the _ssl module
        # to fail
        env['LD_LIBRARY_PATH'] = LIBDIR
    elif ismacos:
        conf += (f' --enable-framework={build_dir()}/python'
                 ' --with-signal-module')
        # Needed for readline detection
        env['MACOSX_DEPLOYMENT_TARGET'] = '10.9'

    with ModifiedEnv(**env):
        simple_build(conf, relocate_pkgconfig=False)

    bindir = os.path.join(build_dir(), 'bin')
    P = os.path.join(bindir, 'python')
    replace_in_file(P + '-config', re.compile(br'^#!.+/bin/', re.MULTILINE),
                    '#!' + PREFIX + '/bin/')
    if ismacos:
        bindir = os.path.join(build_dir(), 'bin')
        for f in os.listdir(bindir):
            link = os.path.join(bindir, f)
            if os.path.islink(link):
                fp = os.readlink(link)
                nfp = fp.replace(build_dir(), PREFIX)
                if nfp != fp:
                    os.unlink(link)
                    os.symlink(nfp, link)
예제 #4
0
파일: webkit.py 프로젝트: eli-schwartz/bypy
def main(args):
    # Control font hinting
    apply_patch('webkit_control_hinting.patch')
    if iswindows:
        return windows_build()

    # fix detection of python2
    if islinux:
        replace_in_file(
            'Source/cmake/WebKitCommon.cmake',
            'find_package(PythonInterp 2.7.0 REQUIRED)',
            'set(PYTHONINTERP_FOUND "ON")\n'
            'set(PYTHON_EXECUTABLE /usr/bin/python2)'
        )

    cmake_build(
        PORT='Qt',
        CMAKE_PREFIX_PATH='{0};{0}/qt'.format(PREFIX),
        override_prefix=os.path.join(build_dir(), 'qt'),
        library_path=True,
        **DISABLE_DIRECTIVES
    )

    for path in walk(build_dir()):
        if path.endswith('.pri'):
            replace_in_file(path, build_dir(), PREFIX)
예제 #5
0
def main(args):
    if ismacos:
        arch = current_build_arch() or 'x86_64'
        run(
            f'./Configure darwin64-{arch}-cc shared enable-ec_nistp_64_gcc_128'
            f' no-ssl2 --prefix={build_dir()} --openssldir={build_dir()}')
        run('make ' + MAKEOPTS)
        run('make install_sw')
    elif iswindows:
        conf = 'perl.exe Configure VC-WIN32 enable-static-engine'.split()
        if is64bit:
            conf[2] = 'VC-WIN64A'
        else:
            conf.append('no-asm')
        conf.append('--prefix=' + build_dir())
        perl_path = os.path.dirname(PERL)
        run(*conf, append_to_path=perl_path)
        run(NMAKE, append_to_path=perl_path)
        run(NMAKE, 'test', append_to_path=perl_path)
        run(NMAKE, 'install', append_to_path=perl_path)
    else:
        optflags = ['enable-ec_nistp_64_gcc_128'] if is64bit else []
        run('./config', '--prefix=/usr', '--openssldir=/etc/ssl', 'shared',
            'zlib', '-Wa,--noexecstack', CFLAGS, LDFLAGS, *optflags)
        run('make ' + MAKEOPTS)
        run('make test', library_path=os.getcwd())
        run('make', 'DESTDIR={}'.format(build_dir()), 'install_sw')
        for x in 'bin lib include'.split():
            os.rename(
                os.path.join(build_dir(), 'usr', x),
                os.path.join(build_dir(), x))
        shutil.rmtree(glob.glob(os.path.join(
            build_dir(), 'lib', 'engines*'))[0])
예제 #6
0
파일: icu.py 프로젝트: kovidgoyal/bypy
def main(args):
    os.chdir('source')

    if iswindows:
        solution_build()
    else:
        build_loc = os.getcwd()
        conf = ('--prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man'
                ' --sbindir=/usr/bin')
        if 'first_build_dir' in lipo_data:
            conf += ' --with-cross-build=' + lipo_data['first_build_dir']

        simple_build(conf,
                     install_args='DESTDIR=' + build_dir(),
                     relocate_pkgconfig=False)
        usr = os.path.join(build_dir(), 'usr')
        os.rename(os.path.join(usr, 'include'),
                  os.path.join(build_dir(), 'include'))
        os.rename(os.path.join(usr, 'lib'), os.path.join(build_dir(), 'lib'))
        for path in walk(build_dir()):
            if path.endswith('.pc'):
                replace_in_file(path,
                                re.compile(br'^prefix\s*=\s*/usr', flags=re.M),
                                f'prefix={PREFIX}')
        shutil.rmtree(usr)

        if 'first_build_dir' not in lipo_data:
            lipo_data['first_build_dir'] = build_loc
예제 #7
0
def main(args):
    if iswindows:
        for f in ('./devel/ftoption.h ./include/freetype/config/ftoption.h'.
                  split()):
            replace_in_file(
                f,
                'FT_BEGIN_HEADER',
                'FT_BEGIN_HEADER\n#define FT_EXPORT(x) __declspec(dllexport) x\n#define FT_EXPORT_DEF(x) __declspec(dllexport) x\n'  # noqa
            )

        def build(static=False):
            conf = 'Release'
            if static:
                conf += ' Static'
            msbuild('builds/windows/vc2010/freetype.sln', configuration=conf)

        # Build the static library
        # build(static=True)
        # install_binaries('objs/freetype.lib')
        # Build the dynamic library
        build()
        install_binaries('objs/freetype.dll', 'bin')
        install_binaries('objs/*/Release/*.lib')
        for f in glob.glob('objs/vc2010/*/freetype*MT.lib'):
            shutil.copy2(f, os.path.join(build_dir(), 'lib', 'freetype.lib'))
        shutil.copytree('include',
                        os.path.join(build_dir(), 'include', 'freetype2'))
        shutil.rmtree(
            os.path.join(build_dir(), 'include', 'freetype2', 'freetype',
                         'internal'))
    else:
        simple_build('--disable-dependency-tracking --disable-static')
예제 #8
0
def main(args):
    if ismacos:
        run('sh ./Configure darwin64-x86_64-cc shared'
            f' enable-ec_nistp_64_gcc_128 no-ssl2 --openssldir={build_dir()}')
        run('make ' + MAKEOPTS)
        run('make install')
    elif iswindows:
        conf = 'perl.exe Configure VC-WIN32 enable-static-engine'.split()
        if is64bit:
            conf[2] = 'VC-WIN64A'
        else:
            conf.append('no-asm')
        conf.append('--prefix=' + build_dir())
        perl_path = os.path.dirname(PERL)
        run(*conf, append_to_path=perl_path)
        bat = r'ms\do_win64a.bat' if is64bit else r'ms\do_ms.bat'
        run(bat, append_to_path=perl_path)
        run(NMAKE, '-f', 'ms/ntdll.mak', append_to_path=perl_path)
        run(NMAKE, '-f', 'ms/ntdll.mak', 'test', append_to_path=perl_path)
        run(NMAKE, '-f', 'ms/ntdll.mak', 'install', append_to_path=perl_path)
    else:
        optflags = ['enable-ec_nistp_64_gcc_128'] if is64bit else []
        run('./config', '--prefix=/usr', '--openssldir=/etc/ssl', 'shared',
            'zlib', '-Wa,--noexecstack', CFLAGS, LDFLAGS, *optflags)
        run('make ' + MAKEOPTS)
        run('make test', library_path=os.getcwd())
        run('make', 'INSTALL_PREFIX={}'.format(build_dir()), 'install_sw')
        for x in 'bin lib include'.split():
            os.rename(os.path.join(build_dir(), 'usr', x),
                      os.path.join(build_dir(), x))
        shutil.rmtree(os.path.join(build_dir(), 'lib', 'engines'))
예제 #9
0
파일: python.py 프로젝트: sudodave/bypy
def windows_python(args):
    with open('PCbuild/msbuild.rsp', 'w') as f:
        print(f'/p:PlatformToolset={get_platform_toolset()}', file=f)
        print(f'/p:WindowsTargetPlatformVersion={get_windows_sdk()}', file=f)

    # dont need python 3 to get externals, use git instead
    replace_in_file('PCbuild\\get_externals.bat',
                    re.compile(br'^call.+find_python.bat.+$', re.MULTILINE),
                    '')
    env = {}
    if is64bit:
        env['PROCESSOR_ARCHITECTURE'] = env['PROCESSOR_ARCHITEW6432'] = 'AMD64'
    try:
        run(
            'PCbuild\\build.bat', '-e', '--no-tkinter', '-c',
            'Release', '-m', '-p', ('x64' if is64bit else 'Win32'), '-v',
            '-t', 'Build',
            '--pgo',
            env=env
        )
        # Run the tests
        # run('PCbuild\\amd64\\python.exe', 'Lib/test/regrtest.py', '-u',
        #     'network,cpu,subprocess,urlfetch')

        # Do not read mimetypes from the registry
        replace_in_file(
            'Lib\\mimetypes.py',
            re.compile(br'try:.*?import\s+winreg.*?None', re.DOTALL),
            r'_winreg = None')

        bindir = 'PCbuild\\amd64' if is64bit else 'PCbuild\\win32'
        install_binaries(bindir + os.sep + '*.exe', 'private\\python')
        install_binaries(bindir + os.sep + 'python*.dll', 'private\\python')
        install_binaries(bindir + os.sep + '*.pyd', 'private\\python\\DLLs')
        install_binaries(bindir + os.sep + '*.dll', 'private\\python\\DLLs')
        for x in glob.glob(
                os.path.join(build_dir(),
                             'private\\python\\DLLs\\python*.dll')):
            os.remove(x)
        install_binaries(bindir + os.sep + '*.lib', 'private\\python\\libs')
        copy_headers('PC\\pyconfig.h', 'private\\python\\include')
        copy_headers('Include\\*.h', 'private\\python\\include')
        copy_headers('Include\\cpython', 'private\\python\\include')
        with open('Lib/sitecustomize.py', 'w') as f:
            f.write('''
import os
for path in ('{p}/bin', '{p}/qt/bin'):
    if os.path.exists(path):
        os.add_dll_directory(path)
'''.format(p=PREFIX.replace('\\', '/')))

        shutil.copytree('Lib', os.path.join(build_dir(),
                                            'private\\python\\Lib'))
    finally:
        # bloody git creates files with no write permission
        import stat
        for path in walk('externals'):
            os.chmod(path, stat.S_IWRITE)
            os.remove(path)
예제 #10
0
파일: automake.py 프로젝트: sudodave/bypy
def main(args):
    with ModifiedEnv(PATH=BIN + os.pathsep + os.environ['PATH']):
        simple_build()
    files = set()
    for path in walk(os.path.join(build_dir(), 'bin')):
        files.add(os.path.abspath(os.path.realpath(path)))
    for path in walk(build_dir()):
        if path.endswith('/Config.pm'):
            files.add(os.path.abspath(os.path.realpath(path)))
    for path in files:
        replace_in_file(path, build_dir(), PREFIX, missing_ok=True)
예제 #11
0
def windows_python2(args):
    replace_in_file(
        'PCbuild\\build.bat', re.compile(r'^\s*%1\s+%2', re.MULTILINE),
        f'"/p:PlatformToolset={get_platform_toolset()}" '
        f'"/p:WindowsTargetPlatformVersion={get_windows_sdk()}"')

    # We create externals/nasm-2.11.06 below so that the
    # python build script does not try to download its own nasm instead
    # using the one we built instead (the python build script fails to
    # mark its nasm as executable, and therefore errors out)
    os.makedirs('externals/nasm-2.11.06')
    # os.makedirs('externals/openssl-1.0.2h')
    # os.makedirs('externals/sqlite-3.8.11.0')
    # os.makedirs('externals/bzip2-1.0.6')

    # dont need python 3 to get externals, use git instead
    replace_in_file('PCbuild\\get_externals.bat',
                    re.compile(br'^call.+find_python.bat.+$', re.MULTILINE),
                    '')
    try:
        run('PCbuild\\build.bat', '-e', '--no-tkinter', '--no-bsddb', '-c',
            'Release', '-m', '-p', ('x64' if is64bit else 'Win32'), '-v', '-t',
            'Build')
        # Run the tests
        # run('PCbuild\\amd64\\python.exe', 'Lib/test/regrtest.py', '-u',
        #     'network,cpu,subprocess,urlfetch')

        # Do not read mimetypes from the registry
        replace_in_file(
            'Lib\\mimetypes.py',
            re.compile(br'try:.*?import\s+_winreg.*?None', re.DOTALL),
            r'_winreg = None')

        bindir = 'PCbuild\\amd64' if is64bit else 'PCbuild'
        install_binaries(bindir + os.sep + '*.exe', 'private\\python')
        install_binaries(bindir + os.sep + 'python*.dll', 'private\\python')
        install_binaries(bindir + os.sep + '*.pyd', 'private\\python\\DLLs')
        install_binaries(bindir + os.sep + '*.dll', 'private\\python\\DLLs')
        for x in glob.glob(
                os.path.join(build_dir(),
                             'private\\python\\DLLs\\python*.dll')):
            os.remove(x)
        install_binaries(bindir + os.sep + '*.lib', 'private\\python\\libs')
        copy_headers('PC\\pyconfig.h', 'private\\python\\include')
        copy_headers('Include\\*.h', 'private\\python\\include')
        shutil.copytree('Lib', os.path.join(build_dir(),
                                            'private\\python\\Lib'))
    finally:
        # bloody git creates files with no write permission
        import stat
        for path in walk('externals'):
            os.chmod(path, stat.S_IWRITE)
            os.remove(path)
예제 #12
0
파일: apsw.py 프로젝트: sudodave/bypy
def main(args):
    if iswindows:
        run(PYTHON, 'setup.py', 'fetch', '--all', '--missing-checksum-ok',
            'build', '--enable-all-extensions', 'install', '--root',
            build_dir())
    else:
        run(PYTHON,
            'setup.py',
            'build',
            'install',
            '--root',
            build_dir(),
            library_path=True)
    python_install()
예제 #13
0
파일: icu.py 프로젝트: eli-schwartz/bypy
def solution_build():
    os.chdir('..')
    try:
        msbuild(r'source\allinone\allinone.sln',
                '/p:SkipUWP=true',
                PYTHONPATH=os.path.abspath(os.path.join('source', 'data')))
    except Exception:
        # the build fails while building the data/tools, which we dont need
        pass
    suffix = '64' if is64bit else ''
    dlls = install_binaries(f'bin{suffix}/icu*.dll', 'bin')
    if len(dlls) < 6:
        raise SystemExit('Failed to build ICU dlls')
    os.remove(glob.glob(os.path.join(build_dir(), 'bin', 'icutest*.dll'))[0])
    install_binaries(f'lib{suffix}/*.lib')
    shutil.copytree('include', os.path.join(build_dir(), 'include'))
예제 #14
0
def run_sip_install(for_webengine=False):
    qt_bin = f'{PREFIX}/qt/bin'
    qmake = 'qmake' + ('.exe' if iswindows else '')
    args = ('--no-docstrings --no-make'
            f' --qmake={qt_bin}/{qmake} --concatenate=5 --verbose').split()
    if iswindows:
        args.append('--link-full-dll')
    if for_webengine:
        args.extend('--disable QtWebEngineQuick'.split())
    else:
        args.extend('--qt-shared --confirm-license --no-designer-plugin'
                    ' --no-qml-plugin'.split())
    run(f'{PREFIX}/bin/sip-build', *args, library_path=True)
    if iswindows:
        # disable distinfo as installing it fails when using INSTALL_ROOT
        replace_in_file('build/Makefile', 'install_distinfo ', ' ')
        run(NMAKE, cwd='build')
        run(NMAKE,
            'install',
            cwd='build',
            env={'INSTALL_ROOT': build_dir()[2:]})
    else:
        run('make ' + MAKEOPTS, cwd='build')
        run(f'make INSTALL_ROOT="{build_dir()}" install',
            cwd='build',
            library_path=True)
    python_install()
예제 #15
0
파일: libxml2.py 프로젝트: kovidgoyal/bypy
def main(args):
    # various cherry picks from HEAD that fix regression in the latest release
    apply_patches('libxml2' + os.sep)
    if iswindows:
        run(*('cscript.exe configure.js include={0}/include'
              ' lib={0}/lib prefix={0} zlib=yes iconv=yes'.format(
                  PREFIX.replace(os.sep, '/')).split()),
            cwd='win32')
        replace_in_file('win32/Makefile.msvc', 'iconv.lib', 'libiconv.lib')
        run(f'"{NMAKE}" /f Makefile.msvc', cwd='win32')
        install_tree('include/libxml', 'include/libxml2')
        for f in walk('.'):
            if f.endswith('.dll'):
                install_binaries(f, 'bin')
            elif f.endswith('.lib'):
                install_binaries(f)
    else:
        # https://gitlab.gnome.org/GNOME/libxml2/-/issues/204
        replace_in_file('encoding.c', re.compile(r'\bTRUE\b'), '1')
        # ICU is needed to use libxml2 in qt-webengine
        simple_build(
            '--disable-dependency-tracking --disable-static --enable-shared'
            ' --without-python --without-debug --with-iconv={0}'
            ' --with-zlib={0} --with-icu'.format(PREFIX))
        for path in walk(build_dir()):
            if path.endswith('/xml2-config'):
                replace_in_file(path, re.compile(b'(?m)^prefix=.+'),
                                f'prefix={PREFIX}')
예제 #16
0
파일: gnuwin32.py 프로젝트: sudodave/bypy
def main(args):
    os.chdir('..')
    dest = os.path.join(build_dir(), 'private')
    os.makedirs(dest)
    srcdir = glob.glob('gnuwin32.zip-*')[0]
    os.rename(srcdir, os.path.join(dest, 'gnuwin32'))
    os.mkdir(srcdir)
예제 #17
0
def main(args):
    if iswindows:
        windows_cmake_build()
        install_binaries('build/jpegtran-static.exe',
                         'bin',
                         fname_map=lambda x: 'jpegtran-calibre.exe')
        install_binaries('build/cjpeg-static.exe',
                         'bin',
                         fname_map=lambda x: 'cjpeg-calibre.exe')
    else:
        env = {}
        if ismacos:
            env['PATH'] = BIN + os.pathsep + os.environ['PATH']
            env['LIBTOOLIZE'] = 'glibtoolize'
            env['LIBTOOL'] = 'glibtool'
        with ModifiedEnv(**env):
            run('autoreconf -fiv')
        conf = ('--disable-dependency-tracking --disable-shared --with-jpeg8'
                ' --without-turbojpeg')
        env = {}
        if ismacos:
            conf += f' --host x86_64-apple-darwin NASM={BIN}/nasm'
            replace_in_file(
                'configure',
                re.compile(br'^PKG_CHECK_MODULES.libpng.+?\bfi\b',
                           re.M | re.DOTALL),
                'HAVE_LIBPNG=1\nHAVE_LIBPNG_TRUE="#"\n')
        simple_build(conf,
                     override_prefix=os.path.join(build_dir(), 'private',
                                                  'mozjpeg'))
예제 #18
0
def build_c_extensions(ext_dir):
    bdir = os.path.join(build_dir(), 'calibre-extension-objects')
    if run(PYTHON, 'setup.py', 'build', '--output-dir', ext_dir, '--build-dir',
           bdir) != 0:
        print('Building of calibre C extensions failed', file=sys.stderr)
        os.chdir(CALIBRE_DIR)
        run_shell()
        raise SystemExit('Building of calibre C extensions failed')
예제 #19
0
def main(args):
    # dbus chooses where to look for config files based on values fed to
    # ./configure, so we cannot configure to install it to prefix
    run('./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var'
        ' --disable-dependency-tracking --disable-static'
        ' --disable-doxygen-docs --disable-xml-docs --disable-systemd'
        ' --without-systemdsystemunitdir'
        ' --with-console-auth-dir=/run/console/ --disable-tests --without-x')
    run('make ' + MAKEOPTS)
    run(f'make install', env={'DESTDIR': build_dir()})
    for x in ('include', 'lib'):
        os.rename(os.path.join(build_dir(), 'usr', x),
                  os.path.join(build_dir(), x))
    shutil.rmtree(os.path.join(build_dir(), 'usr'))
    for path in walk(build_dir()):
        if path.endswith('.pc'):
            replace_in_file(path, 'prefix=/usr', f'prefix={PREFIX}')
예제 #20
0
def main(args):
    run_sip_install()
    if iswindows:
        for x in walk(build_dir()):
            parts = x.replace(os.sep, '/').split('/')
            if parts[-2:] == ['PyQt6', '__init__.py']:
                replace_in_file(x, re.compile(r'^find_qt\(\)', re.M), '')
                break
        else:
            raise ValueError(
                f'Failed to find PyQt6 __init__.py to patch in {build_dir()}')
예제 #21
0
파일: fontconfig.py 프로젝트: sudodave/bypy
def main(args):
    with ModifiedEnv(FREETYPE_CFLAGS='-I%s/include/freetype2' % PREFIX,
                     FREETYPE_LIBS='-L%s/lib -lfreetype -lz -lbz2' % PREFIX):
        simple_build(
            '--disable-dependency-tracking --disable-static --disable-docs'
            f' --with-expat={PREFIX} --with-add-fonts=/usr/share/fonts',
            library_path=True)
    for f in walk(os.path.join(build_dir(), 'etc')):
        if os.path.islink(f):
            x = os.path.realpath(f)
            os.unlink(f)
            shutil.copy2(x, f)
예제 #22
0
파일: icu.py 프로젝트: eli-schwartz/bypy
def cygwin_build():
    for x in 'runConfigureICU configure config.sub config.guess'.split():
        dos2unix(x)
    replace_in_file('configure', 'PYTHONPATH="$srcdir/test/testdata:',
                    'PYTHONPATH="$srcdir/test/testdata;')
    cyg_path = os.pathsep.join(cygwin_paths)
    bdir = build_dir().replace(os.sep, '/')
    run(
        'C:/cygwin64/bin/bash ./runConfigureICU Cygwin/MSVC'
        ' --disable-tools --disable-tests --disable-samples'
        f' --prefix {bdir}',
        append_to_path=cyg_path)
    # parallel builds fail, so no MAKEOPTS
    run('C:/cygwin64/bin/make', append_to_path=cyg_path)
    run('C:/cygwin64/bin/make install', append_to_path=cyg_path)
    for dll in glob.glob(os.path.join(build_dir(), 'lib', '*.dll')):
        if re.search(r'\d+', os.path.basename(dll)) is not None:
            os.rename(dll,
                      os.path.join(build_dir(), 'bin', os.path.basename(dll)))
    for dll in glob.glob(os.path.join(build_dir(), 'lib', '*.dll')):
        os.remove(dll)
예제 #23
0
파일: icu.py 프로젝트: eli-schwartz/bypy
def main(args):
    os.chdir('source')

    if iswindows:
        solution_build()
    elif ismacos:
        run('./runConfigureICU MacOSX --disable-samples --prefix=' +
            build_dir())
        run('make ' + MAKEOPTS)
        run('make install')
    else:
        simple_build(
            '--prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man'
            ' --sbindir=/usr/bin',
            install_args='DESTDIR=' + build_dir(),
            relocate_pkgconfig=False)
        usr = os.path.join(build_dir(), 'usr')
        os.rename(os.path.join(usr, 'include'),
                  os.path.join(build_dir(), 'include'))
        os.rename(os.path.join(usr, 'lib'), os.path.join(build_dir(), 'lib'))
        for path in walk(build_dir()):
            if path.endswith('.pc'):
                replace_in_file(path,
                                re.compile(br'^prefix\s*=\s*/usr', flags=re.M),
                                f'prefix={PREFIX}')
        shutil.rmtree(usr)
예제 #24
0
def main(args):
    # make install tries to write to $HOME/.terminfo
    with ModifiedEnv(HOME=build_dir()):
        simple_build(
            '--with-shared --without-debug --without-ada --enable-widec'
            ' --with-normal --enable-pc-files'
            f' --with-pkg-config-libdir={PKG_CONFIG_PATH}'
            # without the following ncurses will look in the BUILD_DIR
            # for terminfo files even on target systems. Instead use
            # a bunch of common locations.
            ' --with-terminfo-dirs=/usr/share/terminfo:/etc/terminfo:'
            '/lib/terminfo:/usr/lib/terminfo'
            ' --with-default-terminfo-dir=/usr/share/terminfo', )
예제 #25
0
파일: __main__.py 프로젝트: cbhaley/calibre
def build_extensions(env, ext_dir):
    wenv = os.environ.copy()
    wenv.update(worker_env)
    wenv['LD_LIBRARY_PATH'] = LIBDIR
    wenv['QMAKE'] = os.path.join(QT_PREFIX, 'bin', 'qmake')
    wenv['SW'] = PREFIX
    wenv['SIP_BIN'] = os.path.join(PREFIX, 'bin', 'sip')
    p = subprocess.Popen([PYTHON, 'setup.py', 'build', '--build-dir=' + build_dir(), '--output-dir=' + ext_dir], env=wenv, cwd=CALIBRE_DIR)
    if p.wait() != 0:
        os.chdir(CALIBRE_DIR)
        print('building calibre extensions failed', file=sys.stderr)
        run_shell()
        raise SystemExit(p.returncode)
예제 #26
0
파일: init_env.py 프로젝트: zyhong/calibre
def build_c_extensions(ext_dir, args):
    bdir = os.path.join(build_dir(), 'calibre-extension-objects')
    cmd = [
        PYTHON, 'setup.py', 'build',
        '--output-dir', ext_dir, '--build-dir', bdir,
    ]
    if args.build_only:
        cmd.extend(('--only', args.build_only))
    if run(*cmd, COMPILER_CWD=bdir) != 0:
        print('Building of calibre C extensions failed', file=sys.stderr)
        os.chdir(CALIBRE_DIR)
        run_shell()
        raise SystemExit('Building of calibre C extensions failed')
    return ext_dir
예제 #27
0
def main(args):
    replace_in_file('setup.py', 'self._want_assembly_kept = sys',
                    'self._want_assembly_kept = False and sys')
    # the exports in this file lead to linker errors with invalid export
    # specification
    replace_in_file('setup.py',
                    "export_symbol_file = 'com/win32com/src/PythonCOM.def',",
                    '')
    # get rid of some not needed modules and modules that dont build
    replace_in_file(
        'setup.py', 'def _why_cant_build_extension(self, ext):',
        '''def _why_cant_build_extension(self, ext):
        if ext.name in ('exchdapi', 'exchange', 'mapi', 'pythonservice',
                'win32ui', 'win32uiole', 'dde', 'Pythonwin'):
            return 'disabled by Kovid'
        ''')
    # dont copy the MFC Dlls since we have disabled the modules
    # that use them
    replace_in_file(
        'setup.py',
        re.compile(r'^\s+# The MFC DLLs.+?^\s+def ', re.DOTALL | re.MULTILINE),
        '    def ')
    # dont build scintilla (used by the disabled pythonwin)
    replace_in_file('setup.py', 'self._build_scintilla()', '')

    # CLSID_PropertyChangeArray is not useable
    replace_in_file('com/win32comext/propsys/src/propsys.cpp',
                    '#ifndef CLSID_PropertyChangeArray', '#if 0')
    replace_in_file(
        'com/win32comext/propsys/src/propsys.cpp',
        re.compile(r'PYCOM_INTERFACE_CLSID_ONLY\s*\(PropertyChangeArray\),'),
        '')
    # Undefined symbol
    replace_in_file(
        'win32/src/win32job.i',
        '#define JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS JOB_OBJECT_RESERVED_LIMIT_VALID_FLAGS',  # noqa
        '')
    # fix win32com trying to write to paths inside the installation folder
    replace_in_file(
        'com/win32com/__init__.py', "__gen_path__ = ''",
        'import tempfile; __gen_path__ = os.path.join(tempfile.gettempdir(), "gen_py", "%d.%d" % (sys.version_info[0], sys.version_info[1]))'
    )  # noqa
    replace_in_file('com/win32com/client/gencache.py', 'except IOError:',
                    'except Exception:')
    p = windows_sdk_paths()
    with ModifiedEnv(MSSDK_INCLUDE=p['include'], MSSDK_LIB=p['lib']):
        run(PYTHON, 'setup.py', 'build',
            '--plat-name=' + ('win-amd64' if is64bit else 'win32'))
        run(PYTHON, 'setup.py', '-q', 'install', '--root', build_dir())
    base = os.path.relpath(PREFIX, '/')
    q = os.listdir(build_dir())[0]
    os.rename(os.path.join(build_dir(), base, 'private'),
              os.path.join(build_dir(), 'private'))
    rmtree(os.path.join(build_dir(), q))
    rmtree(
        os.path.join(build_dir(),
                     'private/python/Lib/site-packages/pythonwin'))
예제 #28
0
파일: pyqt.py 프로젝트: rayx/bypy
def run_configure(for_webengine=False):
    pyver = python_major_minor_version()
    b = build_dir()
    if ismacos:
        b = os.path.join(
            b, 'python/Python.framework/Versions/{}.{}'.format(*pyver))
    elif iswindows:
        b = os.path.join(b, 'private', 'python')
    lp = os.path.join(PREFIX, 'qt', 'lib')
    sip, qmake = 'sip', 'qmake'
    if iswindows:
        sip += '.exe'
        qmake += '.exe'
    sp = 'Lib' if iswindows else 'lib/python{}.{}'.format(*pyver)
    sip_dir = f'{b}/share/sip/PyQt5'
    dest_dir = f'{b}/{sp}/site-packages'
    if for_webengine:
        pyqt_options = []
        os.makedirs(sip_dir)
        dest_dir += '/PyQt5'
    else:
        pyqt_options = [
            '--confirm-license',
            '--assume-shared',
            f'--bindir={b}/bin',
            '--no-designer-plugin',
            '--no-qml-plugin',
        ]
    cmd = [PYTHON, 'configure.py'] + pyqt_options + [
        '--sip=%s/bin/%s' % (PREFIX, sip),
        '--qmake=%s/qt/bin/%s' % (PREFIX, qmake),
        f'--destdir={dest_dir}',
        '--verbose',
        f'--sipdir={sip_dir}',
        '--no-stubs',
        '-c',
        '-j5',
        '--no-docstrings',
    ]
    if iswindows:
        cmd.append('--spec=win32-msvc')
        cmd.append('--sip-incdir=%s/private/python/include' % PREFIX)
        if for_webengine:
            cmd.append(
                f'--pyqt-sipdir={PREFIX}/private/python/share/sip/PyQt5')
    run(*cmd, library_path=lp)
    return dest_dir
예제 #29
0
def main(args):
    # the makefile stupidly uses a comma as a separator for sed which breaks when there
    # are multiple entries being substituted
    replace_in_file('Makefile.am', re.compile(rb"'s,.+?'"),
                    lambda m: m.group().replace(b',', b'`'))
    replace_in_file('Makefile.in', re.compile(rb"'s,.+?'"),
                    lambda m: m.group().replace(b',', b'`'))
    with ModifiedEnv(FREETYPE_CFLAGS='-I%s/include/freetype2' % PREFIX,
                     FREETYPE_LIBS='-L%s/lib -lfreetype -lz -lbz2' % PREFIX):
        simple_build(
            '--disable-dependency-tracking --disable-static --disable-docs'
            f' --with-expat={PREFIX} --with-add-fonts=/usr/share/fonts',
            library_path=True)
    for f in walk(os.path.join(build_dir(), 'etc')):
        if os.path.islink(f):
            x = os.path.realpath(f)
            os.unlink(f)
            shutil.copy2(x, f)
예제 #30
0
def build_extensions(env, ext_dir):
    wenv = os.environ.copy()
    wenv.update(worker_env)
    wenv['LD_LIBRARY_PATH'] = LIBDIR
    wenv['QMAKE'] = os.path.join(QT_PREFIX, 'bin', 'qmake')
    wenv['SW'] = PREFIX
    wenv['SIP_BIN'] = os.path.join(PREFIX, 'bin', 'sip')
    p = subprocess.Popen([
        PYTHON, 'setup.py', 'build', '--build-dir=' + build_dir(),
        '--output-dir=' + ext_dir
    ],
                         env=wenv,
                         cwd=CALIBRE_DIR)
    if p.wait() != 0:
        os.chdir(CALIBRE_DIR)
        print('building calibre extensions failed', file=sys.stderr)
        run_shell()
        raise SystemExit(p.returncode)
예제 #31
0
파일: __main__.py 프로젝트: zyhong/calibre
def main():
    ext_dir = globals()['ext_dir']
    args = globals()['args']
    run_tests = iv['run_tests']
    env = Env(build_dir())
    initbase(env)
    build_launchers(env)
    build_utils(env)
    freeze(env, ext_dir)
    embed_manifests(env)
    copy_crt_and_d3d(env)
    archive_lib_dir(env)
    if not args.skip_tests:
        run_tests(os.path.join(env.base, 'calibre-debug.exe'), env.base)
    if args.sign_installers:
        sign_executables(env)
    create_installer(env)
    if not is64bit:
        build_portable(env)
        build_portable_installer(env)
    if args.sign_installers:
        sign_installers(env)