Skip to content

Commit 41d4356

Browse files
committed
[skip ci] Add a script to purge old TestPyPI releases.
1 parent fb3605c commit 41d4356

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

purge-test-pypi-releases.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# If TestPyPI complains about size of packages reaching the quota, use Developer Tools to find out
2+
# the session ID (in `Cookie:` header) and CSRF token (in any form submission), and use this script
3+
# to trim old files. THIS OPERATION CANNOT BE UNDONE.
4+
5+
session_id = "<insert-session-id-here>"
6+
csrf_token = "<insert-csrf-token-here>"
7+
8+
projects = []
9+
versions = []
10+
11+
import urllib.parse
12+
import urllib.request
13+
14+
for version in versions:
15+
for project in projects:
16+
request = urllib.request.Request(
17+
f"https://test.pypi.org/manage/project/{project}/release/{version}/",
18+
method="POST",
19+
headers={
20+
"Cookie": f"session_id={session_id}",
21+
"Origin": "https://test.pypi.org",
22+
},
23+
data=urllib.parse.urlencode({
24+
"csrf_token": csrf_token,
25+
"confirm_delete_version": version,
26+
}).encode()
27+
)
28+
urllib.request.urlopen(request)
29+
print(f"deleted {project} {version}")

0 commit comments

Comments
 (0)