Skip to content

Add the ability to exclude selected packages from vendoring upgrades #11503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ def vendoring(session: nox.Session) -> None:
session.run("vendoring", "sync", "-v")
return

# Yes, the UI is bad, we're expecting the user to list packages to *exclude*
# on the command line, without any indication that it's an exclusion. But
# to do better, we'd need to start actually parsing posargs, which is more
# complex than is warranted.
exclude = {pkg for pkg in session.posargs if pkg != "--upgrade"}

# Always exclude setuptools. See
# https://github.com/pypa/pip/commit/1466e7c49ac90cf11f4990a5cb0793aa1a42a3a7
# which was part of https://github.com/pypa/pip/pull/9170
exclude.add("setuptools")

def pinned_requirements(path: Path) -> Iterator[Tuple[str, str]]:
for line in path.read_text().splitlines(keepends=False):
one, sep, two = line.partition("==")
Expand All @@ -199,7 +210,7 @@ def pinned_requirements(path: Path) -> Iterator[Tuple[str, str]]:

vendor_txt = Path("src/pip/_vendor/vendor.txt")
for name, old_version in pinned_requirements(vendor_txt):
if name == "setuptools":
if name in exclude:
continue

# update requirements.txt
Expand Down