def vendoring(session): # type: (nox.Session) -> None session.install("vendoring>=0.3.0") if "--upgrade" not in session.posargs: session.run("vendoring", "sync", ".", "-v") return def pinned_requirements(path): # type: (Path) -> Iterator[Tuple[str, str]] for line in path.read_text().splitlines(keepends=False): one, sep, two = line.partition("==") if not sep: continue name = one.strip() version = two.split("#", 1)[0].strip() if name and version: yield name, version vendor_txt = Path("src/pip/_vendor/vendor.txt") for name, old_version in pinned_requirements(vendor_txt): if name == "setuptools": continue # update requirements.txt session.run("vendoring", "update", ".", name) # get the updated version new_version = old_version for inner_name, inner_version in pinned_requirements(vendor_txt): if inner_name == name: # this is a dedicated assignment, to make flake8 happy new_version = inner_version break else: session.error(f"Could not find {name} in {vendor_txt}") # check if the version changed. if new_version == old_version: continue # no change, nothing more to do here. # synchronize the contents session.run("vendoring", "sync", ".") # Determine the correct message message = f"Upgrade {name} to {new_version}" # Write our news fragment news_file = Path("news") / (name + ".vendor.rst") news_file.write_text(message + "\n") # "\n" appeases end-of-line-fixer # Commit the changes release.commit_file(session, ".", message=message)
def prepare_release(session: nox.Session) -> None: version = release.get_version_from_arguments(session) if not version: session.error("Usage: nox -s prepare-release -- <version>") session.log("# Ensure nothing is staged") if release.modified_files_in_git("--staged"): session.error("There are files staged in git") session.log(f"# Updating {AUTHORS_FILE}") release.generate_authors(AUTHORS_FILE) if release.modified_files_in_git(): release.commit_file(session, AUTHORS_FILE, message=f"Update {AUTHORS_FILE}") else: session.log(f"# No changes to {AUTHORS_FILE}") session.log("# Generating NEWS") release.generate_news(session, version) session.log(f"# Bumping for release {version}") release.update_version_file(version, VERSION_FILE) release.commit_file(session, VERSION_FILE, message="Bump for release") session.log("# Tagging release") release.create_git_tag(session, version, message=f"Release {version}") session.log("# Bumping for development") next_dev_version = release.get_next_development_version(version) release.update_version_file(next_dev_version, VERSION_FILE) release.commit_file(session, VERSION_FILE, message="Bump for development")