Esempio n. 1
0
def main():
    BUILD.mkdir(exist_ok=True)

    try:
        client = docker.from_env()
        client.ping()
    except Exception as e:
        print('unable to connect to Docker: %s' % e)
        return 1

    parser = argparse.ArgumentParser()
    parser.add_argument('--debug', action='store_true')
    parser.add_argument('--platform')
    parser.add_argument('--optimized', action='store_true')
    parser.add_argument('action')

    args = parser.parse_args()

    action = args.action

    name = action
    if args.platform:
        name += '-%s' % args.platform
    if args.debug:
        name += '-debug'
    if args.optimized:
        name += '-pgo'

    platform = args.platform
    musl = False

    if platform and platform.endswith('-musl'):
        musl = True
        platform = platform[:-5]

    log_path = BUILD / ('build.%s.log' % name)
    LOG_PREFIX[0] = name

    with log_path.open('wb') as log_fh:
        LOG_FH[0] = log_fh
        if action == 'versions':
            write_package_versions(BUILD / 'versions')

        elif action.startswith('image-'):
            build_docker_image(client, action[6:])

        elif action == 'binutils':
            build_binutils(client, get_image(client, 'gcc'))

        elif action == 'clang':
            build_clang(client, get_image(client, 'clang'))

        elif action == 'gcc':
            build_gcc(client, get_image(client, 'gcc'))

        elif action == 'musl':
            build_musl(client, get_image(client, 'gcc'))

        elif action == 'libedit':
            build_libedit(client,
                          get_image(client, 'build'),
                          platform=platform,
                          musl=musl)

        elif action == 'readline':
            build_readline(client,
                           get_image(client, 'build'),
                           platform=platform,
                           musl=musl)

        elif action in ('bdb', 'bzip2', 'gdbm', 'inputproto', 'kbproto',
                        'libffi', 'libpthread-stubs', 'libressl', 'ncurses',
                        'openssl', 'sqlite', 'tcl', 'uuid', 'x11-util-macros',
                        'xextproto', 'xorgproto', 'xproto', 'xtrans', 'xz',
                        'zlib'):
            simple_build(client,
                         get_image(client, 'build'),
                         action,
                         platform=platform,
                         musl=musl)

        elif action == 'libX11':
            simple_build(client,
                         get_image(client, 'build'),
                         action,
                         platform=platform,
                         musl=musl,
                         extra_archives={
                             'inputproto',
                             'kbproto',
                             'libpthread-stubs',
                             'libXau',
                             'libxcb',
                             'x11-util-macros',
                             'xextproto',
                             'xorgproto',
                             'xproto',
                             'xtrans',
                         })

        elif action == 'libXau':
            simple_build(client,
                         get_image(client, 'build'),
                         action,
                         platform=platform,
                         musl=musl,
                         extra_archives={'x11-util-macros', 'xproto'})

        elif action == 'xcb-proto':
            simple_build(client,
                         get_image(client, 'xcb'),
                         action,
                         platform=platform,
                         musl=musl)

        elif action == 'libxcb':
            simple_build(client,
                         get_image(client, 'xcb'),
                         action,
                         platform=platform,
                         musl=musl,
                         extra_archives={
                             'libpthread-stubs',
                             'libXau',
                             'xcb-proto',
                             'xproto',
                         })

        elif action == 'tk':
            simple_build(client,
                         get_image(client, 'xcb'),
                         action,
                         platform=platform,
                         musl=musl,
                         extra_archives={
                             'tcl',
                             'libX11',
                             'libXau',
                             'libxcb',
                             'xcb-proto',
                             'xorgproto',
                         })

        elif action == 'cpython':
            build_cpython(client,
                          get_image(client, 'build'),
                          platform=platform,
                          musl=musl,
                          debug=args.debug,
                          optimized=args.optimized,
                          libressl='PYBUILD_LIBRESSL' in os.environ,
                          version=os.environ['PYBUILD_PYTHON_VERSION'][0:3])

        else:
            print('unknown build action: %s' % action)
            return 1
Esempio n. 2
0
def main():
    BUILD.mkdir(exist_ok=True)
    DOWNLOADS_PATH.mkdir(exist_ok=True)
    (BUILD / "logs").mkdir(exist_ok=True)

    if os.environ.get("PYBUILD_NO_DOCKER"):
        client = None
    else:
        try:
            client = docker.from_env()
            client.ping()
        except Exception as e:
            print("unable to connect to Docker: %s" % e)
            return 1

    parser = argparse.ArgumentParser()
    parser.add_argument("--host-platform",
                        required=True,
                        help="Platform we are building from")
    parser.add_argument(
        "--target-triple",
        required=True,
        help="Host triple that we are building Python for",
    )
    parser.add_argument(
        "--optimizations",
        choices={"debug", "noopt", "pgo", "lto", "pgo+lto"},
        required=True,
        help="Optimization profile to use",
    )
    parser.add_argument(
        "--toolchain",
        action="store_true",
        help="Indicates we are building a toolchain artifact",
    )
    parser.add_argument("--dest-archive",
                        required=True,
                        help="Path to archive that we are producing")
    parser.add_argument("action")

    args = parser.parse_args()

    action = args.action

    target_triple = args.target_triple
    host_platform = args.host_platform
    optimizations = args.optimizations
    dest_archive = pathlib.Path(args.dest_archive)

    if args.action == "versions":
        log_name = "versions"
    elif args.action.startswith("image-"):
        log_name = "image-%s" % action
    elif args.toolchain:
        log_name = "%s-%s" % (action, host_platform)
    else:
        entry = DOWNLOADS[action]
        log_name = "%s-%s-%s-%s" % (
            action,
            entry["version"],
            target_triple,
            optimizations,
        )

    log_path = BUILD / "logs" / ("build.%s.log" % log_name)

    with log_path.open("wb") as log_fh:
        set_logger(action, log_fh)
        if action == "versions":
            write_package_versions(BUILD / "versions")

        elif action.startswith("image-"):
            build_docker_image(client, ROOT, BUILD, action[6:])

        elif action == "binutils":
            build_binutils(client, get_image(client, ROOT, BUILD, "gcc"),
                           host_platform)

        elif action == "clang":
            build_clang(
                client,
                get_image(client, ROOT, BUILD, "clang"),
                host_platform=host_platform,
            )

        elif action == "gcc":
            build_gcc(client, get_image(client, ROOT, BUILD, "gcc"),
                      host_platform)

        elif action == "musl":
            build_musl(client, get_image(client, ROOT, BUILD, "gcc"),
                       host_platform)

        elif action == "libedit":
            build_libedit(
                client,
                get_image(client, ROOT, BUILD, "build"),
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
            )

        elif action == "readline":
            build_readline(
                client,
                get_image(client, ROOT, BUILD, "build"),
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
            )

        elif action in (
                "bdb",
                "bzip2",
                "gdbm",
                "gettext",
                "inputproto",
                "kbproto",
                "libffi",
                "libpthread-stubs",
                "libressl",
                "ncurses",
                "openssl",
                "sqlite",
                "tcl",
                "uuid",
                "x11-util-macros",
                "xextproto",
                "xorgproto",
                "xproto",
                "xtrans",
                "xz",
                "zlib",
        ):
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "build"),
                action,
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
            )

        elif action == "libX11":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "build"),
                action,
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
                extra_archives={
                    "inputproto",
                    "kbproto",
                    "libpthread-stubs",
                    "libXau",
                    "libxcb",
                    "x11-util-macros",
                    "xextproto",
                    "xorgproto",
                    "xproto",
                    "xtrans",
                },
            )

        elif action == "libXau":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "build"),
                action,
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
                extra_archives={"x11-util-macros", "xproto"},
            )

        elif action == "xcb-proto":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "xcb"),
                action,
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
            )

        elif action == "libxcb":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "xcb"),
                action,
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
                extra_archives={
                    "libpthread-stubs", "libXau", "xcb-proto", "xproto"
                },
            )

        elif action == "tix":
            build_tix(
                client,
                get_image(client, ROOT, BUILD, "build"),
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
            )

        elif action == "tk":
            extra_archives = {"tcl"}
            if host_platform != "macos":
                extra_archives |= {
                    "libX11",
                    "libXau",
                    "libxcb",
                    "xcb-proto",
                    "xorgproto",
                }

            simple_build(
                client,
                get_image(client, ROOT, BUILD, "xcb"),
                action,
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
                extra_archives=extra_archives,
            )

        elif action in ("cpython-3.8", "cpython-3.9"):
            build_cpython(
                client,
                get_image(client, ROOT, BUILD, "build"),
                host_platform=host_platform,
                target_triple=target_triple,
                optimizations=optimizations,
                dest_archive=dest_archive,
                libressl="PYBUILD_LIBRESSL" in os.environ,
                version=action.split("-")[1],
            )

        else:
            print("unknown build action: %s" % action)
            return 1
Esempio n. 3
0
def main():
    BUILD.mkdir(exist_ok=True)
    DOWNLOADS_PATH.mkdir(exist_ok=True)
    (BUILD / "logs").mkdir(exist_ok=True)

    try:
        client = docker.from_env()
        client.ping()
    except Exception as e:
        if os.environ.get("PYBUILD_NO_DOCKER"):
            client = None
        else:
            print("unable to connect to Docker: %s" % e)
            return 1

    parser = argparse.ArgumentParser()
    parser.add_argument("--debug", action="store_true")
    parser.add_argument("--platform")
    parser.add_argument("--optimized", action="store_true")
    parser.add_argument("action")

    args = parser.parse_args()

    action = args.action

    name = action
    if args.platform:
        name += "-%s" % args.platform
    if args.debug:
        name += "-debug"
    if args.optimized:
        name += "-pgo"

    platform = args.platform
    musl = False

    if platform and platform.endswith("-musl"):
        musl = True
        platform = platform[:-5]

    log_path = BUILD / "logs" / ("build.%s.log" % name)

    with log_path.open("wb") as log_fh:
        set_logger(name, log_fh)
        if action == "versions":
            write_package_versions(BUILD / "versions")

        elif action.startswith("image-"):
            build_docker_image(client, ROOT, BUILD, action[6:])

        elif action == "binutils":
            build_binutils(client, get_image(client, ROOT, BUILD, "gcc"))

        elif action == "clang":
            build_clang(client,
                        get_image(client, ROOT, BUILD, "clang"),
                        platform=platform)

        elif action == "gcc":
            build_gcc(client, get_image(client, ROOT, BUILD, "gcc"))

        elif action == "musl":
            build_musl(client, get_image(client, ROOT, BUILD, "gcc"))

        elif action == "libedit":
            build_libedit(
                client,
                get_image(client, ROOT, BUILD, "build"),
                platform=platform,
                musl=musl,
            )

        elif action == "readline":
            build_readline(
                client,
                get_image(client, ROOT, BUILD, "build"),
                platform=platform,
                musl=musl,
            )

        elif action in (
                "bdb",
                "bzip2",
                "gdbm",
                "inputproto",
                "kbproto",
                "libffi",
                "libpthread-stubs",
                "libressl",
                "ncurses",
                "openssl",
                "sqlite",
                "tcl",
                "uuid",
                "x11-util-macros",
                "xextproto",
                "xorgproto",
                "xproto",
                "xtrans",
                "xz",
                "zlib",
        ):
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "build"),
                action,
                platform=platform,
                musl=musl,
            )

        elif action == "libX11":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "build"),
                action,
                platform=platform,
                musl=musl,
                extra_archives={
                    "inputproto",
                    "kbproto",
                    "libpthread-stubs",
                    "libXau",
                    "libxcb",
                    "x11-util-macros",
                    "xextproto",
                    "xorgproto",
                    "xproto",
                    "xtrans",
                },
            )

        elif action == "libXau":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "build"),
                action,
                platform=platform,
                musl=musl,
                extra_archives={"x11-util-macros", "xproto"},
            )

        elif action == "xcb-proto":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "xcb"),
                action,
                platform=platform,
                musl=musl,
            )

        elif action == "libxcb":
            simple_build(
                client,
                get_image(client, ROOT, BUILD, "xcb"),
                action,
                platform=platform,
                musl=musl,
                extra_archives={
                    "libpthread-stubs", "libXau", "xcb-proto", "xproto"
                },
            )

        elif action == "tix":
            build_tix(
                client,
                get_image(client, ROOT, BUILD, "build"),
                platform=platform,
                musl=musl,
            )

        elif action == "tk":
            extra_archives = {"tcl"}
            if platform != "macos":
                extra_archives |= {
                    "libX11",
                    "libXau",
                    "libxcb",
                    "xcb-proto",
                    "xorgproto",
                }

            simple_build(
                client,
                get_image(client, ROOT, BUILD, "xcb"),
                action,
                platform=platform,
                musl=musl,
                extra_archives=extra_archives,
            )

        elif action == "cpython":
            build_cpython(
                client,
                get_image(client, ROOT, BUILD, "build"),
                platform=platform,
                musl=musl,
                debug=args.debug,
                optimized=args.optimized,
                libressl="PYBUILD_LIBRESSL" in os.environ,
                version=os.environ["PYBUILD_PYTHON_VERSION"][0:3],
            )

        else:
            print("unknown build action: %s" % action)
            return 1