-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_python.ts
More file actions
52 lines (36 loc) · 1.23 KB
/
setup_python.ts
File metadata and controls
52 lines (36 loc) · 1.23 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
import { Client } from "@deno/sandbox";
const client = new Client();
async function initSandbox() {
console.log("Creating a bootable volume...");
const volume = await client.volumes.create({
region: "ord",
slug: "fun-with-python",
capacity: "10GiB",
from: "builtin:debian-13",
});
console.log("Booting a sandbox with the volume as root...");
await using sandbox = await client.sandboxes.create({
region: "ord",
root: volume.slug,
});
console.log("Updating apt and installing Python...");
await sandbox.sh`sudo apt-get update -qq`;
await sandbox.sh`sudo apt-get install -y python3 python3-pip python3-venv python3-dev build-essential`;
console.log("Installing common packages...");
await sandbox.sh`sudo pip3 install --break-system-packages \
requests \
httpx \
numpy \
pandas \
python-dotenv`;
console.log("Verifying Python installation...");
await sandbox.sh`python3 --version`;
await sandbox.sh`pip3 --version`;
return volume.id;
}
const volumeId = await initSandbox();
console.log("Snapshotting the volume...");
const snapshot = await client.volumes.snapshot(volumeId, {
slug: "fun-with-python-snapshot",
});
console.log("Created Python snapshot " + snapshot.id);