Exemple #1
0
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    env = dict(os.environ)
    env['PYTHONUNBUFFERED'] = '1'

    subprocess.run(['make'], cwd=str(MAKE_DIR), env=env, check=True)

    basename = 'cpython-macos'
    extra = ''

    if 'PYBUILD_OPTIMIZED' in os.environ:
        basename += '-pgo'
        extra = '-pgo'

    basename += '.tar'

    source_path = BUILD / basename

    compress_python_archive(
        source_path, DIST,
        'cpython-%s-macos%s-%s' % (DOWNLOADS['cpython-3.7']['version'], extra,
                                   now.strftime('%Y%m%dT%H%M')))
Exemple #2
0
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    env = dict(os.environ)
    env['PYTHONUNBUFFERED'] = '1'

    entry = DOWNLOADS[os.environ['PYBUILD_PYTHON']]
    env['PYBUILD_PYTHON_VERSION'] = entry['version']

    subprocess.run(['make'],
                   cwd=str(MAKE_DIR), env=env, check=True)

    basename = 'cpython-%s-linux64' % entry['version']
    extra = ''

    if 'PYBUILD_MUSL' in os.environ:
        basename += '-musl'
        extra = '-musl'
    if 'PYBUILD_DEBUG' in os.environ:
        basename += '-debug'
        extra += '-debug'
    if 'PYBUILD_OPTIMIZED' in os.environ:
        basename += '-pgo'
        extra = '-pgo'

    basename += '.tar'

    source_path = BUILD / basename
    compress_python_archive(source_path, DIST, 'cpython-%s-linux64%s-%s' % (
        entry['version'], extra,
        now.strftime('%Y%m%dT%H%M')))
Exemple #3
0
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    env = dict(os.environ)
    env["PYTHONUNBUFFERED"] = "1"

    entry = DOWNLOADS[os.environ["PYBUILD_PYTHON"]]
    env["PYBUILD_PYTHON_VERSION"] = entry["version"]

    env["PYBUILD_NO_DOCKER"] = "1"
    env["PYBUILD_UNIX_PLATFORM"] = "macos"

    subprocess.run(["make"], cwd=str(MAKE_DIR), env=env, check=True)

    basename = "cpython-%s-macos" % entry["version"]
    extra = ""

    if "PYBUILD_OPTIMIZED" in os.environ:
        basename += "-pgo"
        extra = "-pgo"

    basename += ".tar"

    source_path = BUILD / basename

    compress_python_archive(
        source_path,
        DIST,
        "cpython-%s-macos%s-%s" %
        (entry["version"], extra, now.strftime("%Y%m%dT%H%M")),
    )
Exemple #4
0
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    env = dict(os.environ)
    env["PYTHONUNBUFFERED"] = "1"

    arch = "x86" if os.environ.get("Platform") == "x86" else "amd64"

    subprocess.run([str(PYTHON), "build.py"],
                   cwd=str(WINDOWS_DIR),
                   env=env,
                   check=True,
                   bufsize=0)

    source_path = BUILD / ("cpython-windows-%s.tar" % arch)

    compress_python_archive(
        source_path,
        DIST,
        "cpython-%s-windows-%s-%s" % (DOWNLOADS["cpython-3.7"]["version"],
                                      arch, now.strftime("%Y%m%dT%H%M")),
    )
Exemple #5
0
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    subprocess.run(['make'], cwd=str(MAKE_DIR), check=True)

    source_path = BUILD / 'cpython-macos.tar'

    compress_python_archive(
        source_path, DIST, 'cpython-%s-macos-%s' %
        (DOWNLOADS['cpython-3.7']['version'], now.strftime('%Y%m%dT%H%M')))
Exemple #6
0
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    env = dict(os.environ)
    env['PYTHONUNBUFFERED'] = '1'

    subprocess.run([str(PYTHON), 'build.py'],
                   cwd=str(WINDOWS_DIR),
                   env=env,
                   check=True,
                   bufsize=0)

    source_path = BUILD / 'cpython-windows.tar'

    compress_python_archive(
        source_path, DIST, 'cpython-%s-windows-amd64-%s' %
        (DOWNLOADS['cpython-3.7']['version'], now.strftime('%Y%m%dT%H%M')))
def run():
    from pythonbuild.downloads import DOWNLOADS
    from pythonbuild.utils import compress_python_archive

    now = datetime.datetime.utcnow()

    env = dict(os.environ)
    env["PYTHONUNBUFFERED"] = "1"

    entry = DOWNLOADS[os.environ["PYBUILD_PYTHON"]]
    env["PYBUILD_PYTHON_VERSION"] = entry["version"]
    env["PYBUILD_PYTHON_MAJOR_VERSION"] = ".".join(
        entry["version"].split(".")[0:2])

    subprocess.run(["make"], cwd=str(MAKE_DIR), env=env, check=True)

    basename = "cpython-%s-linux64" % entry["version"]
    extra = ""

    if "PYBUILD_MUSL" in os.environ:
        basename += "-musl"
        extra = "-musl"
    if "PYBUILD_DEBUG" in os.environ:
        basename += "-debug"
        extra += "-debug"
    if "PYBUILD_OPTIMIZED" in os.environ:
        basename += "-pgo"
        extra = "-pgo"

    basename += ".tar"

    source_path = BUILD / basename
    compress_python_archive(
        source_path,
        DIST,
        "cpython-%s-linux64%s-%s" %
        (entry["version"], extra, now.strftime("%Y%m%dT%H%M")),
    )
def main():
    if sys.platform == "linux":
        host_platform = "linux64"
        default_target_triple = "x86_64-unknown-linux-gnu"
    elif sys.platform == "darwin":
        host_platform = "macos"
        machine = platform.machine()

        if machine == "arm64":
            default_target_triple = "aarch64-apple-darwin"
        elif machine == "x86_64":
            default_target_triple = "x86_64-apple-darwin"
        else:
            raise Exception("unhandled macOS machine value: %s" % machine)
    else:
        print("unsupport build platform: %s" % sys.platform)
        return 1

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "--target-triple",
        default=default_target_triple,
        choices=supported_targets(TARGETS_CONFIG),
        help="Target host triple to build for",
    )

    parser.add_argument(
        "--optimizations",
        choices={"debug", "noopt", "pgo", "lto", "pgo+lto"},
        default="noopt",
        help="Optimizations to apply when compiling Python",
    )
    parser.add_argument(
        "--python",
        choices={"cpython-3.8", "cpython-3.9", "cpython-3.10"},
        default="cpython-3.9",
        help="Python distribution to build",
    )
    parser.add_argument(
        "--break-on-failure",
        action="store_true",
        help="Enter a Python debugger if an error occurs",
    )
    parser.add_argument(
        "--no-docker",
        action="store_true",
        default=True if sys.platform == "darwin" else False,
        help="Disable building in Docker",
    )
    parser.add_argument(
        "--serial",
        action="store_true",
        help="Build packages serially, without parallelism",
    )
    parser.add_argument(
        "--make-target",
        choices={"default", "toolchain"},
        default="default",
        help="The make target to evaluate",
    )

    args = parser.parse_args()

    target_triple = args.target_triple

    settings = get_target_settings(TARGETS_CONFIG, target_triple)

    supported_pythons = {
        "cpython-%s" % p
        for p in settings["pythons_supported"]
    }

    if args.python not in supported_pythons:
        print("%s only supports following Pythons: %s" %
              (target_triple, ", ".join(supported_pythons)))
        return 1

    musl = "musl" in target_triple

    env = dict(os.environ)

    env["PYBUILD_HOST_PLATFORM"] = host_platform
    env["PYBUILD_TARGET_TRIPLE"] = target_triple
    env["PYBUILD_OPTIMIZATIONS"] = args.optimizations
    if musl:
        env["PYBUILD_MUSL"] = "1"
    if args.break_on_failure:
        env["PYBUILD_BREAK_ON_FAILURE"] = "1"
    if args.no_docker:
        env["PYBUILD_NO_DOCKER"] = "1"

    entry = DOWNLOADS[args.python]
    env["PYBUILD_PYTHON_VERSION"] = entry["version"]
    env["PYBUILD_PYTHON_MAJOR_VERSION"] = ".".join(
        entry["version"].split(".")[0:2])

    if "PYBUILD_RELEASE_TAG" in os.environ:
        release_tag = os.environ["PYBUILD_RELEASE_TAG"]
    else:
        release_tag = release_tag_from_git()

    archive_components = [
        "cpython-%s" % entry["version"],
        target_triple,
        args.optimizations,
    ]

    build_basename = "-".join(archive_components) + ".tar"
    dist_basename = "-".join(archive_components + [release_tag])

    # We run make with static parallelism no greater than the machine's CPU count
    # because we can get some speedup from parallel operations. But we also don't
    # share a make job server with each build. So if we didn't limit the
    # parallelism we could easily oversaturate the CPU. Higher levels of
    # parallelism don't result in meaningful build speedups because tk/tix has
    # a long, serial dependency chain that can't be built in parallel.
    parallelism = min(1 if args.serial else 4, multiprocessing.cpu_count())

    subprocess.run(["make", "-j%d" % parallelism, args.make_target],
                   env=env,
                   check=True)

    DIST.mkdir(exist_ok=True)

    if args.make_target == "default":
        compress_python_archive(BUILD / build_basename, DIST, dist_basename)
def main():
    if sys.platform == "linux":
        host_platform = "linux64"
        default_target_triple = "x86_64-unknown-linux-gnu"
    elif sys.platform == "darwin":
        host_platform = "macos"
        machine = platform.machine()

        if machine == "arm64":
            default_target_triple = "aarch64-apple-darwin"
        elif machine == "x86_64":
            default_target_triple = "x86_64-apple-darwin"
        else:
            raise Exception("unhandled macOS machine value: %s" % machine)
    else:
        print("unsupport build platform: %s" % sys.platform)
        return 1

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "--target-triple",
        default=default_target_triple,
        choices=supported_targets(TARGETS_CONFIG),
        help="Target host triple to build for",
    )

    parser.add_argument(
        "--optimizations",
        choices={"debug", "noopt", "pgo", "lto", "pgo+lto"},
        default="noopt",
        help="Optimizations to apply when compiling Python",
    )

    parser.add_argument("--libressl",
                        action="store_true",
                        help="Build LibreSSL instead of OpenSSL")
    parser.add_argument(
        "--python",
        choices={"cpython-3.8", "cpython-3.9", "cpython-3.10"},
        default="cpython-3.9",
        help="Python distribution to build",
    )
    parser.add_argument(
        "--break-on-failure",
        action="store_true",
        help="Enter a Python debugger if an error occurs",
    )
    parser.add_argument(
        "--no-docker",
        action="store_true",
        default=True if sys.platform == "darwin" else False,
        help="Disable building in Docker",
    )
    parser.add_argument(
        "--skip-toolchain",
        action="store_true",
        help=
        "Skip building the toolchain (requires a tar file in expected location)",
    )
    parser.add_argument(
        "--make-target",
        choices={"default", "toolchain"},
        default="default",
        help="The make target to evaluate",
    )

    args = parser.parse_args()

    target_triple = args.target_triple

    settings = get_target_settings(TARGETS_CONFIG, target_triple)

    if args.python not in settings["pythons_supported"]:
        print("%s only supports following Pythons: %s" %
              (target_triple, ", ".join(settings["pythons_supported"])))
        return 1

    musl = "musl" in target_triple

    env = dict(os.environ)

    env["PYBUILD_HOST_PLATFORM"] = host_platform
    env["PYBUILD_TARGET_TRIPLE"] = target_triple
    env["PYBUILD_OPTIMIZATIONS"] = args.optimizations
    if args.libressl or musl:
        env["PYBUILD_LIBRESSL"] = "1"
    if musl:
        env["PYBUILD_MUSL"] = "1"
    if args.break_on_failure:
        env["PYBUILD_BREAK_ON_FAILURE"] = "1"
    if args.no_docker:
        env["PYBUILD_NO_DOCKER"] = "1"
    if args.skip_toolchain:
        env["PYBUILD_SKIP_TOOLCHAIN"] = "1"

    entry = DOWNLOADS[args.python]
    env["PYBUILD_PYTHON_VERSION"] = entry["version"]
    env["PYBUILD_PYTHON_MAJOR_VERSION"] = ".".join(
        entry["version"].split(".")[0:2])

    if "PYBUILD_RELEASE_TAG" in os.environ:
        release_tag = os.environ["PYBUILD_RELEASE_TAG"]
    else:
        release_tag = release_tag_from_git()

    archive_components = [
        "cpython-%s" % entry["version"],
        target_triple,
        args.optimizations,
    ]

    build_basename = "-".join(archive_components) + ".tar"
    dist_basename = "-".join(archive_components + [release_tag])

    subprocess.run(["make", args.make_target], env=env, check=True)

    DIST.mkdir(exist_ok=True)

    if args.make_target == "default":
        compress_python_archive(BUILD / build_basename, DIST, dist_basename)
def main():
    if sys.platform == "linux":
        host_platform = "linux64"
        default_target_triple = "x86_64-unknown-linux-gnu"
        targets = {
            default_target_triple,
            "x86_64-unknown-linux-musl",
        }
    elif sys.platform == "darwin":
        host_platform = "macos"
        default_target_triple = "x86_64-apple-darwin"
        targets = {default_target_triple}
    else:
        print("unsupport build platform: %s" % sys.platform)
        return 1

    parser = argparse.ArgumentParser()

    parser.add_argument(
        "--target-triple",
        default=default_target_triple,
        choices=targets,
        help="Target host triple to build for",
    )

    parser.add_argument(
        "--optimizations",
        choices={"debug", "noopt", "pgo", "lto", "pgo+lto"},
        default="noopt",
        help="Optimizations to apply when compiling Python",
    )

    parser.add_argument("--libressl",
                        action="store_true",
                        help="Build LibreSSL instead of OpenSSL")
    parser.add_argument(
        "--python",
        choices={"cpython-3.7", "cpython-3.8"},
        default="cpython-3.7",
        help="Python distribution to build",
    )
    parser.add_argument(
        "--no-docker",
        action="store_true",
        default=True if sys.platform == "darwin" else False,
        help="Disable building in Docker",
    )

    args = parser.parse_args()

    target_triple = args.target_triple

    musl = "musl" in target_triple

    env = dict(os.environ)

    env["PYBUILD_HOST_PLATFORM"] = host_platform
    env["PYBUILD_TARGET_TRIPLE"] = target_triple
    env["PYBUILD_OPTIMIZATIONS"] = args.optimizations
    if args.libressl or musl:
        env["PYBUILD_LIBRESSL"] = "1"
    if musl:
        env["PYBUILD_MUSL"] = "1"
    if args.no_docker:
        env["PYBUILD_NO_DOCKER"] = "1"

    entry = DOWNLOADS[args.python]
    env["PYBUILD_PYTHON_VERSION"] = entry["version"]
    env["PYBUILD_PYTHON_MAJOR_VERSION"] = ".".join(
        entry["version"].split(".")[0:2])

    if "PYBUILD_RELEASE_TAG" in os.environ:
        release_tag = os.environ["PYBUILD_RELEASE_TAG"]
    else:
        now = datetime.datetime.utcnow()
        release_tag = now.strftime("%Y%m%dT%H%M")

    archive_components = [
        "cpython-%s" % entry["version"],
        target_triple,
        args.optimizations,
    ]

    build_basename = "-".join(archive_components) + ".tar"
    dist_basename = "-".join(archive_components + [release_tag])

    subprocess.run(["make"], env=env, check=True)

    DIST.mkdir(exist_ok=True)

    compress_python_archive(BUILD / build_basename, DIST, dist_basename)