forked from pypa/get-pip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
113 lines (90 loc) · 3.76 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import shutil
import textwrap
import webbrowser
from pathlib import Path
import nox
nox.options.sessions = ["check", "generate"]
# Keep versions in sync with .github/workflows/check.yml
@nox.session(
python=["2.6", "2.7", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
)
def check(session):
"""Ensure that get-pip.py for various Python versions, works on that version."""
# Find the appropriate get-pip.py file
public = Path("public")
locations = [
public / session.python / "get-pip.py",
public / "get-pip.py",
]
for location in locations:
if location.exists():
break
else: # AKA nobreak
raise RuntimeError("There is no public get-pip.py")
# Get rid of provided-by-nox pip
session.run("python", "-m", "pip", "uninstall", "pip", "--yes")
# Run the pip.pyz file
session.run("python", "scripts/check_zipapp.py", str(public / "pip.pyz"), "--version")
# Run the get-pip.py file
session.run("python", str(location))
# Ensure that pip is installed
session.run("python", "-m", "pip", "--version")
session.run("pip", "--version")
@nox.session
def generate(session):
"""Update the scripts, to the latest versions."""
session.install("packaging", "requests", "urllib3<2", "cachecontrol[filecache]", "rich", "pkg_metadata")
public = Path("public")
shutil.rmtree(public, ignore_errors=True)
session.run("python", "scripts/generate.py")
@nox.session(name="update-for-release")
def update_for_release(session):
"""Automation to run after a pip release."""
allowed_upstreams = [
"git@github.com:pypa/get-pip.git",
"https://github.com/pypa/get-pip.git",
]
if len(session.posargs) != 1:
session.error("Usage: nox -s update-for-release -- <released-pip-version>")
(release_version,) = session.posargs
session.install("release-helper")
session.run("release-helper", "version-check-validity", release_version)
session.run("release-helper", "git-check-tag", release_version, "--does-not-exist")
session.run("release-helper", "git-check-remote", "upstream", *allowed_upstreams)
session.run("release-helper", "git-check-branch", "main")
session.run("release-helper", "git-check-clean")
release_branch = f"release/{release_version}"
session.run("git", "branch", release_branch, external=True)
session.run("git", "checkout", release_branch, external=True)
# Generate the scripts.
generate(session)
# Make the commit and present it to the user.
session.run("git", "add", ".", external=True)
session.run("git", "commit", "-m", f"Update to {release_version}", external=True)
session.run("git", "show", "HEAD", "--stat", external=True)
input(
textwrap.dedent(
f"""\
**********************************************
* IMPORTANT: Check which files got modified. *
**********************************************
This script will now generate a "signed" git tag for this commit and
push the tag and release branch to pypa/get-pip. You will need to:
- File a PR from the `{release_branch}` branch.
- Merge it once the CI passes (no need to wait on reviews).
- Delete the `{release_branch}` branch on pypa/get-pip.
"""
)
)
session.run(
# fmt: off
"git", "tag", release_version, "-m", f"Release {release_version}",
"--annotate", "--sign",
external=True,
# fmt: on
)
session.run("git", "push", "upstream", "HEAD", release_version, external=True)
session.run("git", "checkout", "main", external=True)
webbrowser.open_new_tab(
f"https://github.com/pypa/get-pip/compare/{release_branch}?expand=1"
)