コード例 #1
0
def build_release(session):
    version = release.get_version_from_arguments(session.posargs)
    if not version:
        session.error("Usage: nox -s build-release -- YY.N[.P]")

    session.log("# Ensure no files in dist/")
    if release.have_files_in_folder("dist"):
        session.error(
            "There are files in dist/. Remove them and try again. "
            "You can use `git clean -fxdi -- dist` command to do this"
        )

    session.log("# Install dependencies")
    session.install("setuptools", "wheel", "twine")

    session.log("# Checkout the tag")
    session.run("git", "checkout", version, external=True, silent=True)

    session.log("# Cleanup build/ before building the wheel")
    if release.have_files_in_folder("build"):
        shutil.rmtree("build")

    session.log("# Build distributions")
    session.run("python", "setup.py", "sdist", "bdist_wheel", silent=True)

    session.log("# Verify distributions")
    session.run("twine", "check", *glob.glob("dist/*"), silent=True)

    session.log("# Checkout the master branch")
    session.run("git", "checkout", "master", external=True, silent=True)
コード例 #2
0
ファイル: noxfile.py プロジェクト: dwt/pip
def build_release(session):
    # type: (nox.Session) -> None
    version = release.get_version_from_arguments(session)
    if not version:
        session.error("Usage: nox -s build-release -- YY.N[.P]")

    session.log("# Ensure no files in dist/")
    if release.have_files_in_folder("dist"):
        session.error(
            "There are files in dist/. Remove them and try again. "
            "You can use `git clean -fxdi -- dist` command to do this"
        )

    session.log("# Install dependencies")
    session.install("setuptools", "wheel", "twine")

    with release.isolated_temporary_checkout(session, version) as build_dir:
        session.log(
            "# Start the build in an isolated, "
            f"temporary Git checkout at {build_dir!s}",
        )
        with release.workdir(session, build_dir):
            tmp_dists = build_dists(session)

        tmp_dist_paths = (build_dir / p for p in tmp_dists)
        session.log(f"# Copying dists from {build_dir}")
        os.makedirs('dist', exist_ok=True)
        for dist, final in zip(tmp_dist_paths, tmp_dists):
            session.log(f"# Copying {dist} to {final}")
            shutil.copy(dist, final)
コード例 #3
0
ファイル: noxfile.py プロジェクト: yuki-sakuma/pip
def build_release(session):
    version = release.get_version_from_arguments(session.posargs)
    if not version:
        session.error("Usage: nox -s build-release -- YY.N[.P]")

    session.log("# Ensure no files in dist/")
    if release.have_files_in_folder("dist"):
        session.error(
            "There are files in dist/. Remove them and try again. "
            "You can use `git clean -fxdi -- dist` command to do this"
        )

    session.log("# Install dependencies")
    session.install("setuptools", "wheel", "twine")

    with release.isolated_temporary_checkout(session, version) as build_dir:
        session.log(
            "# Start the build in an isolated, "
            f"temporary Git checkout at {build_dir!s}",
        )
        with release.workdir(session, build_dir):
            tmp_dists = build_dists(session)

        tmp_dist_paths = (build_dir / p for p in tmp_dists)
        session.log(f"# Copying dists from {build_dir}")
        shutil.rmtree('dist', ignore_errors=True)  # remove empty `dist/`
        for dist in tmp_dist_paths:
            session.log(f"# Copying {dist}")
            shutil.copy(dist, 'dist')