-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall-pythons
More file actions
executable file
·58 lines (45 loc) · 1.57 KB
/
install-pythons
File metadata and controls
executable file
·58 lines (45 loc) · 1.57 KB
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
#!/usr/bin/env python3.11
from __future__ import annotations
import argparse
import glob
import os
import subprocess
VERSIONS = ("3.11.14", "3.12.12", "3.13.12", "3.14.3")
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--dest", default="/opt/python")
args = parser.parse_args()
os.makedirs(args.dest, exist_ok=True)
subprocess.check_call(
("uv", "python", "install", *VERSIONS, "--install-dir", args.dest),
)
for version in VERSIONS:
major, minor, *_ = version.split(".")
# uv installs to e.g. cpython-3.14.3-linux-aarch64-gnu/
matches = glob.glob(os.path.join(args.dest, f"cpython-{major}.{minor}.*"))
if len(matches) != 1:
raise AssertionError(
f"expected exactly one match for cpython-{major}.{minor}.*, "
f"got {matches}"
)
installed_dir = matches[0]
# symlink cpXY-cpXY -> the uv-installed directory for PATH compat
link = os.path.join(args.dest, f"cp{major}{minor}-cp{major}{minor}")
os.symlink(os.path.basename(installed_dir), link)
py = os.path.join(link, "bin", "python3")
subprocess.check_call(
(
"uv",
"pip",
"install",
"--python",
py,
"pip==25.0.1",
"setuptools==75.8.0",
"wheel==0.45.1",
),
)
subprocess.check_call((py, "--version", "--version"))
return 0
if __name__ == "__main__":
raise SystemExit(main())