-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpip_upgrade_outdated.py
More file actions
executable file
·48 lines (40 loc) · 997 Bytes
/
pip_upgrade_outdated.py
File metadata and controls
executable file
·48 lines (40 loc) · 997 Bytes
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
#!/usr/bin/env python
from json import loads
from subprocess import run
from sys import executable
def pip_list_outdated():
list_stdout = run(
[
executable,
"-m",
"pip",
"--disable-pip-version-check",
"list",
"--outdated",
"--format=json",
],
check=True,
capture_output=True,
text=True,
).stdout
return [package["name"] for package in loads(list_stdout)]
def pip_upgrade_list(packages=[]):
if packages:
run(
[
executable,
"-m",
"pip",
"install",
"--root-user-action=ignore",
"--upgrade",
"--no-cache-dir",
"--no-compile",
]
+ packages,
check=True,
)
def pip_upgrade_all():
outdated = pip_list_outdated()
pip_upgrade_list(outdated)
pip_upgrade_all()