示例#1
0
def main(args: argparse.Namespace) -> None:
    check_path()

    rel = version.StrictVersion(args.release)
    platforms = [
        "win_amd64",
        "manylinux2010_x86_64",
        "manylinux2014_aarch64",
        "macosx_10_14_x86_64.macosx_10_15_x86_64.macosx_11_0_x86_64",
    ]
    print("Release:", rel)
    major, minor, patch = rel.version
    branch = "release_" + str(major) + "." + str(minor) + ".0"
    git.clean("-xdf")
    git.checkout(branch)
    git.pull("origin", branch)
    git.submodule("update")
    commit_hash = lastest_hash()

    dir_URL = PREFIX + str(major) + "." + str(minor) + ".0" + "/"
    src_filename_prefix = "xgboost-" + args.release + "%2B" + commit_hash + "-py3-none-"
    target_filename_prefix = "xgboost-" + args.release + "-py3-none-"

    if not os.path.exists(DIST):
        os.mkdir(DIST)

    filenames = download_wheels(platforms, dir_URL, src_filename_prefix,
                                target_filename_prefix)
    print("List of downloaded wheels:", filenames)
    print("""
Following steps should be done manually:
- Generate source package by running `python setup.py sdist`.
- Upload pypi package by `python3 -m twine upload dist/<Package Name>` for all wheels.
- Check the uploaded files on `https://pypi.org/project/xgboost/<VERSION>/#files` and `pip
  install xgboost==<VERSION>` """)
示例#2
0
def main(args: argparse.Namespace) -> None:
    check_path()

    rel = version.LooseVersion(args.release)

    print("Release:", rel)
    if len(rel.version) == 3:
        # Major release
        major, minor, patch = version.StrictVersion(args.release).version
        rc = None
        rc_ver = None
    else:
        # RC release
        major, minor, patch, rc, rc_ver = cast(Tuple[int, int, int, str, int],
                                               rel.version)
        assert rc == "rc"

    release = str(major) + "." + str(minor) + "." + str(patch)
    branch = "release_" + release
    git.clean("-xdf")
    git.checkout(branch)
    git.pull("origin", branch)
    git.submodule("update")
    commit_hash = latest_hash()

    download_r_packages(release, "" if rc is None else rc + str(rc_ver),
                        commit_hash)

    download_py_packages(major, minor, commit_hash)
示例#3
0
def clone_commit(cirpy_dir, commit):
    """ Clones the `circuitpython` repository, fetches the commit, then
        checks out the repo at that ref.
    """
    working_dir = pathlib.Path()

    rosiepi_logger.info("Cloning repository at reference: %s", commit)

    try:
        git.clone("--depth", "1", "-n",
                  "https://github.com/sommersoft/circuitpython.git", cirpy_dir)

        os.chdir(cirpy_dir)
        git.fetch("origin", commit)

        git.checkout(commit)

        git.submodule("sync")

        git.submodule("update", "--init")

    except sh.ErrorReturnCode as git_err:
        git_stderr = str(git_err.stderr, encoding="utf-8").strip("\n")
        err_msg = [
            f"Failed to retrive repository at {commit}:",
            f" - {git_stderr}",
        ]
        rosiepi_logger.warning("%s", "\n".join(err_msg))
        raise RuntimeError(git_stderr) from None

    finally:
        os.chdir(working_dir)
示例#4
0
def update_bundle(bundle_path):
    working_directory = os.path.abspath(os.getcwd())
    os.chdir(bundle_path)
    git.submodule("foreach", "git", "fetch")
    # sh fails to find the subcommand so we use subprocess.
    subprocess.run(shlex.split(
        "git submodule foreach 'git checkout -q `git rev-list --tags --max-count=1`'"
    ),
                   stdout=subprocess.DEVNULL)

    status = StringIO()
    result = git.status("--short", _out=status)
    updates = []
    status = status.getvalue().strip()
    if status:
        for status_line in status.split("\n"):
            action, directory = status_line.split()
            if action != "M" or not directory.startswith("libraries"):
                raise RuntimeError("Unsupported updates")

            # Compute the tag difference.
            diff = StringIO()
            result = git.diff("--submodule=log", directory, _out=diff)
            diff_lines = diff.getvalue().split("\n")
            commit_range = diff_lines[0].split()[2]
            commit_range = commit_range.strip(":").split(".")
            old_commit = commit_to_tag(directory, commit_range[0])
            new_commit = commit_to_tag(directory, commit_range[-1])
            url = repo_remote_url(directory)
            summary = "\n".join(diff_lines[1:-1])
            updates.append((url[:-4], old_commit, new_commit, summary))
    os.chdir(working_directory)
    return updates
示例#5
0
def fetch_bundle(bundle, bundle_path):
    if not os.path.isdir(bundle_path):
        os.makedirs(bundle_path, exist_ok=True)
        git.clone("-o", "adafruit",
                  "https://github.com/adafruit/" + bundle + ".git",
                  bundle_path)
    working_directory = os.getcwd()
    os.chdir(bundle_path)
    git.pull()
    git.submodule("init")
    git.submodule("update")
    os.chdir(working_directory)
示例#6
0
def fetch_bundle(bundle, bundle_path):
    if not os.path.isdir(bundle_path):
        os.makedirs(bundle_path, exist_ok=True)
        if "GITHUB_WORKSPACE" in os.environ:
            git_url = "https://" + os.environ["ADABOT_GITHUB_ACCESS_TOKEN"] + "@github.com/adafruit/"
            git.clone("-o", "adafruit", git_url + bundle + ".git", bundle_path)
        else:
            git.clone("-o", "adafruit", "https://github.com/adafruit/" + bundle + ".git", bundle_path)
    working_directory = os.getcwd()
    os.chdir(bundle_path)
    git.pull()
    git.submodule("init")
    git.submodule("update")
    os.chdir(working_directory)
示例#7
0
def update_bundle(bundle_path):
    working_directory = os.path.abspath(os.getcwd())
    os.chdir(bundle_path)
    git.submodule("foreach", "git", "fetch")
    # Regular release tags are 'x.x.x'. Exclude tags that are alpha or beta releases.
    # They will contain a '-' in the tag, such as '3.0.0-beta.5'.
    # --exclude must be before --tags.
    # sh fails to find the subcommand so we use subprocess.
    subprocess.run(shlex.split(
        "git submodule foreach 'git checkout -q `git rev-list --exclude='*-*' --tags --max-count=1`'"
    ),
                   stdout=subprocess.DEVNULL)
    status = StringIO()
    result = git.status("--short", _out=status)
    updates = []
    status = status.getvalue().strip()
    if status:
        for status_line in status.split("\n"):
            action, directory = status_line.split()
            if directory.endswith("library_list.md"):
                continue
            if action != "M" or not directory.startswith("libraries"):
                raise RuntimeError("Unsupported updates")

            # Compute the tag difference.
            diff = StringIO()
            result = git.diff("--submodule=log", directory, _out=diff)
            diff_lines = diff.getvalue().split("\n")
            commit_range = diff_lines[0].split()[2]
            commit_range = commit_range.strip(":").split(".")
            old_commit = commit_to_tag(directory, commit_range[0])
            new_commit = commit_to_tag(directory, commit_range[-1])
            url = repo_remote_url(directory)
            summary = "\n".join(diff_lines[1:-1])
            updates.append((url[:-4], old_commit, new_commit, summary))
    os.chdir(working_directory)
    lib_list_updates = check_lib_links_md(bundle_path)
    if lib_list_updates:
        updates.append((
            "https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md",
            "NA", "NA", "  > Added the following libraries: {}".format(
                ", ".join(lib_list_updates))))

    return updates
示例#8
0
def main(args: argparse.Namespace) -> None:
    check_path()

    rel = version.parse(args.release)
    assert isinstance(rel, version.Version)

    major = rel.major
    minor = rel.minor
    patch = rel.micro

    print("Release:", rel)
    if not rel.is_prerelease:
        # Major release
        rc: Optional[str] = None
        rc_ver: Optional[int] = None
    else:
        # RC release
        major = rel.major
        minor = rel.minor
        patch = rel.micro
        assert rel.pre is not None
        rc, rc_ver = rel.pre
        assert rc == "rc"

    release = str(major) + "." + str(minor) + "." + str(patch)
    branch = "release_" + release
    git.clean("-xdf")
    git.checkout(branch)
    git.pull("origin", branch)
    git.submodule("update")
    commit_hash = latest_hash()

    download_r_packages(
        release, "" if rc is None else rc + str(rc_ver), commit_hash
    )

    download_py_packages(major, minor, commit_hash)
示例#9
0
def update_json_file(working_directory, cp_org_dir, output_filename,
                     json_string):
    """ Clone the circuitpython-org repo, update libraries.json, and push the updates
        in a commit.
    """
    if "TRAIVS" in os.environ:
        if not os.path.isdir(cp_org_dir):
            os.makedirs(cp_org_dir, exist_ok=True)
            git_url = "https://" + os.environ[
                "ADABOT_GITHUB_ACCESS_TOKEN"] + "@github.com/adafruit/circuitpython-org.git"
            git.clone("-o", "adafruit", git_url, cp_org_dir)
        os.chdir(cp_org_dir)
        git.pull()
        git.submodule("update", "--init", "--recursive")

        with open(output_filename, "w") as json_file:
            json.dump(json_string, json_file, indent=2)

        commit_day = date.date.strftime(datetime.datetime.today(), "%Y-%m-%d")
        commit_msg = "adabot: auto-update of libraries.json ({})".format(
            commit_day)
        git.commit("-a", "-m", commit_msg)
        git_push = git.push("adafruit", "master")
        print(git_push)
示例#10
0
def build_fw(board, build_ref, test_log):  # pylint: disable=too-many-locals,too-many-statements
    """ Builds the firware at `build_ref` for `board`. Firmware will be
        output to `.fw_builds/<build_ref>/<board>/`.

    :param: str board: Name of the board to build firmware for.
    :param: str build_ref: The tag/commit to build firmware for.
    :param: test_log: The TestController.log used for output.
    """
    working_dir = os.getcwd()
    cirpy_ports_dir = pathlib.Path(cirpy_dir(), "ports")

    board_port_dir = None
    for port in _AVAILABLE_PORTS:
        port_dir = cirpy_ports_dir / port / "boards" / board
        if port_dir.exists():
            board_port_dir = (cirpy_ports_dir / port).resolve()
            rosiepi_logger.info("Board source found: %s", board_port_dir)
            break

    if board_port_dir is None:
        err_msg = [
            f"'{board}' board not available to test. Can't build firmware.",
            #"="*60,
            #"Closing RosiePi"
        ]
        raise RuntimeError("\n".join(err_msg))

    build_dir = pathlib.Path.home() / ".fw_builds" / build_ref[:5] / board

    os.chdir(cirpy_dir())
    try:
        test_log.write("Fetching {}...".format(build_ref))
        git.fetch("--depth", "1", "origin", build_ref)

        test_log.write("Checking out {}...".format(build_ref))
        git.checkout(build_ref)

        test_log.write("Syncing submodules...")
        git.submodule("sync")

        test_log.write("Updating submodules...")
        git.submodule("update", "--init", "--depth", "1")
    except sh.ErrorReturnCode as git_err:
        # TODO: change to 'master'
        git.checkout("-f", "rosiepi_test")
        os.chdir(working_dir)
        err_msg = [
            "Building firmware failed:",
            " - {}".format(str(git_err.stderr, encoding="utf-8").strip("\n")),
            #"="*60,
            #"Closing RosiePi"
        ]
        raise RuntimeError("\n".join(err_msg)) from None

    os.chdir(board_port_dir)
    board_cmd = (f"make clean BOARD={board} BUILD={build_dir}",
                 f"make BOARD={board} BUILD={build_dir}")

    test_log.write("Building firmware...")
    try:
        rosiepi_logger.info("Running make recipe: %s", '; '.join(board_cmd))
        run_envs = {
            "BASH_ENV": "/etc/profile",
        }

        rosiepi_logger.info("Running build clean...")
        # pylint: disable=subprocess-run-check
        subprocess.run(
            board_cmd[0],
            shell=True,
            stdout=subprocess.DEVNULL,
            stderr=subprocess.STDOUT,
            executable="/usr/bin/bash",
            start_new_session=True,
            env=run_envs,
        )

        build_dir.mkdir(mode=0o0774, parents=True)

        # pylint: enable=subprocess-run-check
        rosiepi_logger.info("Running firmware build...")
        fw_build = subprocess.run(
            board_cmd[1],
            check=True,
            shell=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            executable="/usr/bin/bash",
            start_new_session=True,
            env=run_envs,
        )

        result = str(fw_build.stdout, encoding="utf-8").split("\n")
        success_msg = [line for line in result if "bytes" in line]
        test_log.write(" - " + "\n - ".join(success_msg))
        rosiepi_logger.info("Firmware built...")

    except subprocess.CalledProcessError as cmd_err:
        # TODO: change to 'master'
        git.checkout("-f", "rosiepi_test")
        os.chdir(working_dir)
        err_msg = [
            "Building firmware failed:",
            " - {}".format(str(cmd_err.stdout, encoding="utf-8").strip("\n")),
            #"="*60,
            #"Closing RosiePi"
        ]
        rosiepi_logger.warning("Firmware build failed...")
        raise RuntimeError("\n".join(err_msg)) from None

    finally:
        # TODO: change to 'master'
        git.checkout("-f", "rosiepi_test")
        os.chdir(working_dir)

    return build_dir