1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Add automation for upgrading dependencies

Signed-off-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
This commit is contained in:
Pradyun Gedam 2020-11-19 13:56:28 +00:00
parent c41bbe5248
commit 7c3028fa4d
No known key found for this signature in database
GPG key ID: FF99710C4332258E

View file

@ -8,6 +8,7 @@ import glob
import os
import shutil
import sys
from pathlib import Path
import nox
@ -152,9 +153,50 @@ def lint(session):
@nox.session
def vendoring(session):
session.install("vendoring")
session.install("vendoring>=0.3.0")
session.run("vendoring", "sync", ".", "-v")
if "--upgrade" not in session.posargs:
session.run("vendoring", "sync", ".", "-v")
return
def pinned_requirements(path):
for line in path.read_text().splitlines():
one, two = line.split("==", 1)
name = one.strip()
version = two.split("#")[0].strip()
yield name, version
vendor_txt = Path("src/pip/_vendor/vendor.txt")
for name, old_version in pinned_requirements(vendor_txt):
# 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)
# -----------------------------------------------------------------------------