pythsol 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. pythsol/__init__.py +317 -0
  2. pythsol/cli/__init__.py +7 -0
  3. pythsol/cli/cache.py +78 -0
  4. pythsol/cli/cluster.py +45 -0
  5. pythsol/cli/commands/build.py +214 -0
  6. pythsol/cli/commands/check.py +54 -0
  7. pythsol/cli/commands/client_cmd.py +97 -0
  8. pythsol/cli/commands/deploy.py +103 -0
  9. pythsol/cli/commands/docs_cmd.py +62 -0
  10. pythsol/cli/commands/doctor.py +211 -0
  11. pythsol/cli/commands/emit_c.py +69 -0
  12. pythsol/cli/commands/faucet.py +66 -0
  13. pythsol/cli/commands/idl_cmd.py +69 -0
  14. pythsol/cli/commands/idl_publish.py +80 -0
  15. pythsol/cli/commands/init.py +65 -0
  16. pythsol/cli/commands/port_cmd.py +42 -0
  17. pythsol/cli/commands/profile.py +57 -0
  18. pythsol/cli/commands/serve.py +52 -0
  19. pythsol/cli/commands/test_cmd.py +217 -0
  20. pythsol/cli/commands/verify.py +96 -0
  21. pythsol/cli/commands/wallet.py +128 -0
  22. pythsol/cli/config.py +84 -0
  23. pythsol/cli/main.py +72 -0
  24. pythsol/cli/rpc.py +56 -0
  25. pythsol/cli/template_programs/__init__.py +1 -0
  26. pythsol/cli/template_programs/counter.py +52 -0
  27. pythsol/cli/template_programs/escrow.py +75 -0
  28. pythsol/cli/template_programs/ledger.py +68 -0
  29. pythsol/cli/template_programs/multisig.py +91 -0
  30. pythsol/cli/template_programs/poll.py +70 -0
  31. pythsol/cli/template_programs/vault.py +67 -0
  32. pythsol/cli/templates.py +192 -0
  33. pythsol/client/__init__.py +5 -0
  34. pythsol/client/from_idl.py +356 -0
  35. pythsol/client/gen.py +496 -0
  36. pythsol/client/port.py +355 -0
  37. pythsol/compiler/__init__.py +39 -0
  38. pythsol/compiler/diagnostics.py +130 -0
  39. pythsol/compiler/emit.py +3550 -0
  40. pythsol/compiler/front.py +84 -0
  41. pythsol/compiler/idl.py +465 -0
  42. pythsol/compiler/model.py +1329 -0
  43. pythsol/compiler/modules.py +320 -0
  44. pythsol/compiler/parse.py +59 -0
  45. pythsol/compiler/pipeline.py +152 -0
  46. pythsol/compiler/resolve.py +518 -0
  47. pythsol/compiler/subset.py +1061 -0
  48. pythsol/compiler/toolchain.py +438 -0
  49. pythsol/compiler/typecheck.py +2447 -0
  50. pythsol/playground/__init__.py +7 -0
  51. pythsol/playground/app.css +182 -0
  52. pythsol/playground/app.js +260 -0
  53. pythsol/playground/apple-touch-icon.png +0 -0
  54. pythsol/playground/docs.html +61 -0
  55. pythsol/playground/favicon-32.png +0 -0
  56. pythsol/playground/favicon.ico +0 -0
  57. pythsol/playground/favicon.svg +24 -0
  58. pythsol/playground/hero-bg.webp +0 -0
  59. pythsol/playground/index.html +66 -0
  60. pythsol/playground/landing.html +810 -0
  61. pythsol/playground/playground.html +77 -0
  62. pythsol/playground/robots.txt +4 -0
  63. pythsol/playground/server.py +336 -0
  64. pythsol/playground/site-bg.svg +146 -0
  65. pythsol/playground/site.css +1105 -0
  66. pythsol/py.typed +0 -0
  67. pythsol/refrt/__init__.py +200 -0
  68. pythsol/runtime/__init__.py +17 -0
  69. pythsol/runtime/pythsol_rt.h +1216 -0
  70. pythsol/testing/__init__.py +12 -0
  71. pythsol/testing/plugin.py +437 -0
  72. pythsol-0.1.0.dist-info/METADATA +178 -0
  73. pythsol-0.1.0.dist-info/RECORD +76 -0
  74. pythsol-0.1.0.dist-info/WHEEL +4 -0
  75. pythsol-0.1.0.dist-info/entry_points.txt +6 -0
  76. pythsol-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,7 @@
1
+ """Local playground: check and emit on 127.0.0.1. No user code is executed."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pythsol.playground.server import bind
6
+
7
+ __all__ = ["bind"]
@@ -0,0 +1,182 @@
1
+ :root {
2
+ color-scheme: light;
3
+ --bg: #ffffff;
4
+ --bg-subtle: #f5f8fc;
5
+ --surface: #f3f6fa;
6
+ --text: #1b2430;
7
+ --muted: #4a5668;
8
+ --border: #d5dde8;
9
+ --blue: #306998;
10
+ --blue-strong: #255077;
11
+ --yellow: #ffd43b;
12
+ --purple: #9945ff;
13
+ --mint: #14f195;
14
+ --ok: #1a7f4b;
15
+ --warn: #8a5a0a;
16
+ --err: #b3462e;
17
+ }
18
+ * { box-sizing: border-box; }
19
+ body {
20
+ margin: 0;
21
+ font-family: "Segoe UI", sans-serif;
22
+ background: transparent;
23
+ color: var(--text);
24
+ }
25
+ .tools-bar {
26
+ display: flex;
27
+ flex-wrap: wrap;
28
+ gap: 12px;
29
+ align-items: center;
30
+ padding: 14px 20px;
31
+ background: var(--bg-subtle);
32
+ border-bottom: 1px solid var(--border);
33
+ }
34
+ /* The brand mark styles live in site.css (`nav .mark`). */
35
+ header p { margin: 0; color: var(--muted); flex: 1; font-size: 14px; }
36
+ .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
37
+ button, select { font: inherit; }
38
+ button {
39
+ background: var(--blue);
40
+ color: #fff;
41
+ border: 0;
42
+ border-radius: 6px;
43
+ padding: 8px 12px;
44
+ font-weight: 600;
45
+ display: inline-flex;
46
+ align-items: center;
47
+ gap: 6px;
48
+ transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
49
+ }
50
+ button .ico { width: 14px; height: 14px; flex: none; }
51
+ /* JS hides the Compile button when /healthz says compile:false; the flex
52
+ display above would otherwise defeat the hidden attribute. */
53
+ button[hidden] { display: none; }
54
+ button:not(:disabled):hover { background: var(--blue-strong); }
55
+ button.quiet:not(:disabled):hover { background: #fff; border-color: var(--blue); color: var(--blue-strong); }
56
+ .tab:not(.on):not(:disabled):hover { background: #fff; border-color: var(--blue); color: var(--blue-strong); }
57
+ #reset .ico { transition: transform 0.2s ease; }
58
+ @media (prefers-reduced-motion: no-preference) {
59
+ #reset:hover .ico { transform: rotate(-30deg); }
60
+ }
61
+ button:focus-visible, select:focus-visible {
62
+ outline: 2px solid var(--blue-strong);
63
+ outline-offset: 2px;
64
+ }
65
+ button.quiet { background: #fff; color: var(--blue); border: 1px solid var(--border); }
66
+ button:disabled { opacity: 0.55; cursor: progress; }
67
+ select { padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
68
+
69
+ main {
70
+ display: grid;
71
+ grid-template-columns: 1fr 1fr;
72
+ gap: 18px;
73
+ padding: 18px 20px 26px;
74
+ align-items: stretch;
75
+ }
76
+
77
+ /* Coordinated panes: warm label bar over a quiet code surface.
78
+ Both panes share one explicit height; the bodies flex, so the tab row
79
+ in the result pane never makes the columns uneven. */
80
+ .pane {
81
+ display: flex;
82
+ flex-direction: column;
83
+ min-width: 0;
84
+ height: clamp(420px, calc(64vh + 110px), 780px);
85
+ border: 1px solid var(--border);
86
+ border-radius: 8px;
87
+ background: #fff;
88
+ overflow: hidden;
89
+ }
90
+ .pane-head {
91
+ display: flex;
92
+ gap: 10px;
93
+ align-items: center;
94
+ justify-content: space-between;
95
+ padding: 8px 12px;
96
+ background: var(--bg-subtle);
97
+ border-bottom: 1px solid var(--border);
98
+ }
99
+ .pane-head h3 {
100
+ margin: 0;
101
+ font-size: 12.5px;
102
+ letter-spacing: 0.05em;
103
+ text-transform: uppercase;
104
+ color: var(--muted);
105
+ display: flex;
106
+ align-items: center;
107
+ gap: 7px;
108
+ }
109
+ .pane-head .ico { width: 15px; height: 15px; color: var(--blue-strong); flex: none; }
110
+ .hint {
111
+ font-size: 12px;
112
+ color: var(--muted);
113
+ font-family: ui-monospace, Consolas, monospace;
114
+ white-space: nowrap;
115
+ }
116
+ .pane textarea,
117
+ .pane pre {
118
+ display: block;
119
+ flex: 1 1 0;
120
+ min-height: 0;
121
+ width: 100%;
122
+ margin: 0;
123
+ padding: 12px;
124
+ border: 0;
125
+ border-radius: 0;
126
+ background: var(--surface);
127
+ font-family: ui-monospace, Consolas, monospace;
128
+ font-size: 13px;
129
+ line-height: 1.5;
130
+ }
131
+ .pane textarea { resize: none; }
132
+ .pane pre { overflow: auto; border-left: 3px solid transparent; }
133
+ textarea:focus-visible,
134
+ .pane pre:focus-visible {
135
+ outline: 2px solid var(--blue-strong);
136
+ outline-offset: -2px;
137
+ }
138
+ /* Output states: the glyph-free tint travels with the text, so color is
139
+ never the only signal ("No problems." and the codes carry the meaning). */
140
+ pre.on-ok { border-left-color: var(--ok); background: #f2f9f4; }
141
+ pre.on-diag { border-left-color: var(--warn); background: #fbf6e8; }
142
+ pre.on-err { border-left-color: var(--err); background: #fdf0ed; }
143
+ pre.on-info { border-left-color: transparent; }
144
+
145
+ .tabs {
146
+ display: flex;
147
+ gap: 8px;
148
+ align-items: center;
149
+ padding: 8px 12px;
150
+ border-bottom: 1px solid var(--border);
151
+ }
152
+ /* JS toggles the `hidden` attribute; re-assert display so diagnostics and
153
+ the empty state never show artifact tabs. */
154
+ .tabs[hidden] { display: none; }
155
+ .tablist { display: flex; gap: 6px; }
156
+ .tab {
157
+ background: #fff;
158
+ color: var(--muted);
159
+ border: 1px solid var(--border);
160
+ border-radius: 6px;
161
+ padding: 4px 10px;
162
+ font-size: 13px;
163
+ font-weight: 600;
164
+ cursor: pointer;
165
+ }
166
+ .tab.on {
167
+ background: var(--blue);
168
+ color: #fff;
169
+ border-color: var(--blue);
170
+ }
171
+ .tab.copy { margin-left: auto; }
172
+
173
+ footer {
174
+ padding: 12px 20px 24px;
175
+ color: var(--muted);
176
+ font-size: 13px;
177
+ }
178
+ @media (max-width: 800px) {
179
+ main { grid-template-columns: 1fr; padding: 14px 12px 20px; gap: 14px; }
180
+ .tools-bar { padding: 12px 14px; }
181
+ .pane { height: clamp(300px, calc(54vh + 96px), 700px); }
182
+ }
@@ -0,0 +1,260 @@
1
+ const source = document.getElementById("source");
2
+ const out = document.getElementById("out");
3
+ const example = document.getElementById("example");
4
+ const tabs = document.getElementById("tabs");
5
+ const buttons = ["check", "emit", "compile"].map((id) => document.getElementById(id));
6
+ const tabButtons = ["c", "idl", "client"].map((id) => document.getElementById("tab-" + id));
7
+ const views = { c: "", idl: "", client: "" };
8
+ let cursor = "";
9
+
10
+ /* One consumer of the output surface: the state class adds a colored
11
+ edge to the text, which always carries the meaning itself. */
12
+ function show(text, state) {
13
+ out.textContent = text;
14
+ out.className = state || "on-info";
15
+ }
16
+
17
+ /* Emit artifacts live in three panes; Check and other output hides the tabs. */
18
+ function openTabs(payload) {
19
+ views.c = payload.c || "";
20
+ views.idl = payload.idl || "";
21
+ views.client = payload.client || "";
22
+ cursor = views.c;
23
+ if (!views.c) {
24
+ tabs.hidden = true;
25
+ return;
26
+ }
27
+ tabs.hidden = false;
28
+ setTab("c");
29
+ }
30
+
31
+ function closeTabs() {
32
+ views.c = views.idl = views.client = "";
33
+ cursor = "";
34
+ tabs.hidden = true;
35
+ }
36
+
37
+ function setTab(which, focus) {
38
+ cursor = views[which] || "";
39
+ out.textContent = cursor || "Nothing for this tab yet.";
40
+ tabButtons.forEach((button) => {
41
+ const on = button.id === "tab-" + which;
42
+ button.classList.toggle("on", on);
43
+ button.setAttribute("aria-selected", String(on));
44
+ button.tabIndex = on ? 0 : -1;
45
+ if (on && focus) {
46
+ button.focus();
47
+ }
48
+ });
49
+ }
50
+
51
+ tabButtons.forEach((button) => {
52
+ button.addEventListener("click", () => setTab(button.id.slice(4)));
53
+ button.addEventListener("keydown", (event) => {
54
+ const order = ["c", "idl", "client"];
55
+ const at = order.indexOf(button.id.slice(4));
56
+ let next = -1;
57
+ if (event.key === "ArrowRight" || event.key === "ArrowDown") {
58
+ next = (at + 1) % order.length;
59
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
60
+ next = (at + order.length - 1) % order.length;
61
+ } else if (event.key === "Home") {
62
+ next = 0;
63
+ } else if (event.key === "End") {
64
+ next = order.length - 1;
65
+ }
66
+ if (next >= 0) {
67
+ event.preventDefault();
68
+ setTab(order[next], true);
69
+ }
70
+ });
71
+ });
72
+
73
+ document.getElementById("copy").addEventListener("click", async () => {
74
+ if (!cursor) {
75
+ return;
76
+ }
77
+ const copy = document.getElementById("copy");
78
+ const label = copy.querySelector(".lbl") || copy;
79
+ try {
80
+ await navigator.clipboard.writeText(cursor);
81
+ label.textContent = "Copied";
82
+ setTimeout(() => {
83
+ label.textContent = "Copy";
84
+ }, 1200);
85
+ } catch (err) {
86
+ label.textContent = "Copy failed";
87
+ setTimeout(() => {
88
+ label.textContent = "Copy";
89
+ }, 1600);
90
+ show(cursor + "\n\n(Copy failed — select the text above.)", "on-info");
91
+ }
92
+ });
93
+
94
+ source.addEventListener("keydown", (event) => {
95
+ if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {
96
+ event.preventDefault();
97
+ document.getElementById("check").click();
98
+ }
99
+ });
100
+
101
+ function formatDiagnostics(rows) {
102
+ if (!rows || !rows.length) {
103
+ return "No problems.";
104
+ }
105
+ return rows
106
+ .map((row) => {
107
+ const where = row.file ? row.file + ":" + row.line + ":" + row.col + " " : "";
108
+ const fix = row.fix ? "\n fix: " + row.fix : "";
109
+ return where + row.code + " " + row.message + fix;
110
+ })
111
+ .join("\n\n");
112
+ }
113
+
114
+ /* Brief button feedback: the label says what happened, then restores. */
115
+ function flash(id, label) {
116
+ const button = document.getElementById(id);
117
+ if (!button) {
118
+ return;
119
+ }
120
+ const span = button.querySelector(".lbl") || button;
121
+ const original = span.textContent;
122
+ span.textContent = label;
123
+ setTimeout(() => {
124
+ span.textContent = original;
125
+ }, 1400);
126
+ }
127
+
128
+ async function post(path, body, label) {
129
+ if (!source.value.trim()) {
130
+ show("Choose an example or paste a program first.", "on-info");
131
+ return;
132
+ }
133
+ buttons.forEach((button) => {
134
+ if (button) {
135
+ button.disabled = true;
136
+ }
137
+ });
138
+ out.setAttribute("aria-busy", "true");
139
+ show(label, "on-info");
140
+ try {
141
+ const response = await fetch(path, {
142
+ method: "POST",
143
+ headers: { "content-type": "application/json" },
144
+ body: JSON.stringify(body),
145
+ });
146
+ const payload = await response.json();
147
+ const rendered = render(path, response.status, payload);
148
+ show(rendered.text, rendered.state);
149
+ } catch (err) {
150
+ show("The playground did not answer.\n" + err, "on-err");
151
+ } finally {
152
+ out.removeAttribute("aria-busy");
153
+ buttons.forEach((button) => {
154
+ if (button) {
155
+ button.disabled = false;
156
+ }
157
+ });
158
+ }
159
+ }
160
+
161
+ function render(path, status, payload) {
162
+ if (payload.diagnostics && payload.diagnostics.length) {
163
+ closeTabs();
164
+ return { text: formatDiagnostics(payload.diagnostics), state: "on-diag" };
165
+ }
166
+ if (payload.ok === false) {
167
+ closeTabs();
168
+ const code = payload.code ? payload.code + " " : "";
169
+ return {
170
+ text: code + (payload.error || "Request failed (" + status + ")."),
171
+ state: "on-err",
172
+ };
173
+ }
174
+ if (path === "/v1/check") {
175
+ closeTabs();
176
+ flash("check", "\u2713 Checked");
177
+ return { text: "No problems.", state: "on-ok" };
178
+ }
179
+ if (path === "/v1/emit") {
180
+ if (!payload.idl && !payload.client) {
181
+ closeTabs();
182
+ return { text: payload.c || "Emit succeeded, but no C was returned.", state: "on-ok" };
183
+ }
184
+ openTabs(payload);
185
+ flash("emit", "C ready");
186
+ return { text: views.c, state: "on-ok" };
187
+ }
188
+ if (path === "/v1/compile") {
189
+ closeTabs();
190
+ flash("compile", "\u2713 Built");
191
+ return {
192
+ text: "Built program.so\nsha256 " + payload.so_sha256 + "\ncache " + payload.cache,
193
+ state: "on-ok",
194
+ };
195
+ }
196
+ closeTabs();
197
+ return { text: "Done.", state: "on-ok" };
198
+ }
199
+
200
+ async function loadExample(name) {
201
+ const response = await fetch("/examples/" + name);
202
+ if (!response.ok) {
203
+ show("Could not load the " + name + " example.", "on-err");
204
+ return false;
205
+ }
206
+ source.value = await response.text();
207
+ closeTabs();
208
+ show("Loaded " + name + ". Check it, show the C, or compile.", "on-info");
209
+ return true;
210
+ }
211
+
212
+ document.getElementById("reset").addEventListener("click", () => {
213
+ loadExample(example.value || "counter");
214
+ });
215
+
216
+ example.addEventListener("change", () => {
217
+ loadExample(example.value);
218
+ });
219
+
220
+ document.getElementById("check").addEventListener("click", () => {
221
+ post("/v1/check", { source: source.value, filename: "program.py" }, "Checking…");
222
+ });
223
+
224
+ document.getElementById("emit").addEventListener("click", () => {
225
+ post("/v1/emit", { source: source.value, filename: "program.py" }, "Generating C…");
226
+ });
227
+
228
+ document.getElementById("compile").addEventListener("click", () => {
229
+ post("/v1/compile", { source: source.value, filename: "program.py" }, "Compiling… this can take a moment.");
230
+ });
231
+
232
+ fetch("/healthz")
233
+ .then((response) => response.json())
234
+ .then((health) => {
235
+ if (!health.compile) {
236
+ const button = document.getElementById("compile");
237
+ button.hidden = true;
238
+ }
239
+ })
240
+ .catch(() => {});
241
+
242
+ fetch("/examples")
243
+ .then((response) => response.json())
244
+ .then((payload) => {
245
+ const names = payload.examples || [];
246
+ names.forEach((name) => {
247
+ const option = document.createElement("option");
248
+ option.value = name;
249
+ option.textContent = name;
250
+ example.appendChild(option);
251
+ });
252
+ if (names.length) {
253
+ loadExample(names[0]);
254
+ } else {
255
+ show("No examples are installed.", "on-info");
256
+ }
257
+ })
258
+ .catch((err) => {
259
+ show("Could not load examples.\n" + err, "on-err");
260
+ });
Binary file
@@ -0,0 +1,61 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Docs — PythSol</title>
7
+ <link rel="icon" href="/favicon.ico" />
8
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg?v=2" />
9
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
10
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
11
+ <link rel="stylesheet" href="/site.css" />
12
+ </head>
13
+ <body>
14
+ <svg width="0" height="0" class="sprite" aria-hidden="true">
15
+ <defs>
16
+ <g id="i-terminal"><path d="M4 5h16v14H4zM7.5 9.5l2.5 2.5-2.5 2.5M12.5 15H17" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></g>
17
+ <g id="i-book"><path d="M5 3h13a1 1 0 0 1 1 1v13.5H5A1.5 1.5 0 0 1 3.5 16V4.5A1.5 1.5 0 0 1 5 3zM3.5 17.5A1.5 1.5 0 0 0 5 19h14M7 7h8M7 10.5h8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></g>
18
+ <g id="i-tools"><path d="M14.7 6.3a4 4 0 0 0-5.3 5L4 16.8V20h3.2l5.5-5.4a4 4 0 0 0 5-5.3L15 12l-3-3z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></g>
19
+ <g id="i-browser"><path d="M4 5h16v14H4zM4 9h16M7 7h.1M9.5 7h.1" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></g>
20
+ <g id="i-github"><path d="M12 2.2a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.7c-2.7.6-3.3-1.3-3.3-1.3-.4-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 .1 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.3-1.1.6-1.3-2.2-.3-4.5-1.1-4.5-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.7 1a9.3 9.3 0 0 1 5 0c1.9-1.3 2.7-1 2.7-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.5 4.9.3.3.6.9.6 1.8v2.7c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.2z" fill="currentColor"/></g>
21
+ </defs>
22
+ </svg>
23
+ <nav>
24
+ <a class="mark" href="/"><span class="po">Pyth</span><span class="so">Sol</span></a>
25
+ <a class="item" href="/docs">Docs</a>
26
+ <a class="item" href="/playground">Playground</a>
27
+ <a class="item gh" href="https://github.com/PythSol/pythsol" target="_blank" rel="noopener"><svg class="nav-ico" viewBox="0 0 24 24" aria-hidden="true"><use href="#i-github"/></svg>GitHub</a>
28
+ </nav>
29
+ <header class="hero">
30
+ <h1>Docs</h1>
31
+ <p>The short built-in reference. Full documentation lives at <a href="/docs">pythsol.com/docs</a>.</p>
32
+ </header>
33
+ <div class="wrap">
34
+ <h2><svg class="h2-mark" viewBox="0 0 24 24" aria-hidden="true"><use href="#i-terminal"/></svg>Quick start</h2>
35
+ <pre>pip install -e ".[test]"
36
+ pythsol init app --template counter
37
+ cd app
38
+ pythsol check programs/app.py
39
+ pythsol test
40
+ pythsol build</pre>
41
+ <p class="note"><code>pythsol test</code> needs pytest and solders. <code>pythsol build</code> needs the SBF platform tools (<code>pythsol doctor</code> names them).</p>
42
+ <h2><svg class="h2-mark" viewBox="0 0 24 24" aria-hidden="true"><use href="#i-book"/></svg>Language</h2>
43
+ <p>Annotated integers <code>u8</code> through <code>u128</code> and <code>i8</code> through <code>i128</code>, <code>bool</code>, <code>Pubkey</code>, <code>Signer</code>, <code>Mut</code>, <code>Init</code>, <code>FixedArray</code>, <code>Option</code>, <code>FixedString</code>, <code>Vec[T, N]</code>, unit enums, and data enums written as <code>Name: u64</code>.</p>
44
+ <p>Still rejected: a <code>Vec</code> with no capacity, f-strings, and a generic on-chain invoke. One PDA seed, letters, digits, and <code>_</code>.</p>
45
+ <p>A fixed-range list comprehension, <code>[base + i for i in range(4)]</code>, initializes a <code>FixedArray[T, 4]</code> local at compile time.</p>
46
+ <h2><svg class="h2-mark" viewBox="0 0 24 24" aria-hidden="true"><use href="#i-tools"/></svg>CLI</h2>
47
+ <pre>pythsol doctor
48
+ pythsol check PROGRAM.py
49
+ pythsol build PROGRAM.py
50
+ pythsol test
51
+ pythsol idl PROGRAM.py
52
+ pythsol client PROGRAM.py -o client.py
53
+ pythsol deploy --dry-run --so program.so
54
+ pythsol serve</pre>
55
+ <h2><svg class="h2-mark" viewBox="0 0 24 24" aria-hidden="true"><use href="#i-browser"/></svg>Playground</h2>
56
+ <p><a href="/playground">The playground</a> loads counter, ledger, vault, escrow, multisig, and poll. Check and Show C use the compiler. Compile .so runs clang when this server is on loopback and the tools are installed.</p>
57
+ <p class="note">A longer docs site is also built with Starlight from <code>web/docs</code> (<code>npm run build</code>, then serve <code>dist/</code>). This page is the one that ships with <code>pythsol serve</code>.</p>
58
+ </div>
59
+ <footer>Light theme only. Version 0.1.0.</footer>
60
+ </body>
61
+ </html>
Binary file
Binary file
@@ -0,0 +1,24 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
2
+ <defs>
3
+ <linearGradient id="pg" x1="0" y1="0" x2="0" y2="1">
4
+ <stop offset="0" stop-color="#ffd43b"/>
5
+ <stop offset="1" stop-color="#e8a20c"/>
6
+ </linearGradient>
7
+ <linearGradient id="sg" x1="0" y1="0" x2="1" y2="0">
8
+ <stop offset="0" stop-color="#14f195"/>
9
+ <stop offset="1" stop-color="#9945ff"/>
10
+ </linearGradient>
11
+ </defs>
12
+ <g
13
+ font-family="'Segoe UI', Arial, 'Helvetica Neue', sans-serif"
14
+ font-weight="900"
15
+ font-size="24"
16
+ stroke="#23262f"
17
+ stroke-width="1.15"
18
+ stroke-linejoin="round"
19
+ paint-order="stroke"
20
+ >
21
+ <text x="1.8" y="24.1" textLength="14.6" lengthAdjust="spacingAndGlyphs" fill="url(#pg)">P</text>
22
+ <text x="14.2" y="24.1" textLength="14.6" lengthAdjust="spacingAndGlyphs" fill="url(#sg)">S</text>
23
+ </g>
24
+ </svg>
Binary file
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>PythSol — write Solana programs in Python</title>
7
+ <link rel="icon" href="/favicon.ico" />
8
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg?v=2" />
9
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
10
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
11
+ <link rel="stylesheet" href="/site.css" />
12
+ </head>
13
+ <body>
14
+ <nav>
15
+ <a class="mark" href="/">Pyth<span>Sol</span></a>
16
+ <a class="item" href="/docs">Docs</a>
17
+ <a class="item" href="/playground">Playground</a>
18
+ </nav>
19
+ <header class="hero">
20
+ <h1>Write Solana programs in Python.</h1>
21
+ <p>
22
+ PythSol compiles a typed Python subset to a native SBF program and an
23
+ Anchor-style IDL. It does not run your Python, and it does not generate Rust.
24
+ </p>
25
+ <div class="actions">
26
+ <a href="/docs">Get started</a>
27
+ <a class="quiet" href="/playground">Open the playground</a>
28
+ </div>
29
+ </header>
30
+ <div class="wrap">
31
+ <div class="split">
32
+ <section>
33
+ <h2>program.py</h2>
34
+ <pre>def increment(authority: Signer, counter: Mut[Counter], by: u64) -> None:
35
+ require(counter.authority == authority.key, CounterError.Unauthorized)
36
+ counter.count += by</pre>
37
+ </section>
38
+ <section>
39
+ <h2>What the compiler writes</h2>
40
+ <div class="steps">
41
+ <article class="step"><strong>Signer.</strong> The authority must have signed.</article>
42
+ <article class="step"><strong>Mut.</strong> The account must be writable, owned, and the right size.</article>
43
+ <article class="step"><strong>u64.</strong> Arguments are length-checked and read little-endian.</article>
44
+ <article class="step"><strong>require.</strong> A failure returns 6000 + index and the source line.</article>
45
+ <article class="step"><strong>+=</strong> Integer math is checked. Overflow aborts.</article>
46
+ <article class="step"><strong>IDL.</strong> The same model writes the IDL and a client.</article>
47
+ </div>
48
+ </section>
49
+ </div>
50
+ <h2>Four commands</h2>
51
+ <div class="commands">
52
+ <article class="command"><strong>pythsol init</strong><p class="note">Writes pysol.toml, a program, and a LiteSVM test.</p></article>
53
+ <article class="command"><strong>pythsol test</strong><p class="note">Builds the program and runs it in LiteSVM.</p></article>
54
+ <article class="command"><strong>pythsol build</strong><p class="note">Writes the .so, the IDL, the generated C, and a client.</p></article>
55
+ <article class="command"><strong>pythsol deploy</strong><p class="note">Runs solana program deploy. Mainnet needs --yes.</p></article>
56
+ </div>
57
+ <div class="cards">
58
+ <article class="card"><h3>Docs</h3><p>Install, the language, and the CLI.</p><a href="/docs">Read the docs</a></article>
59
+ <article class="card"><h3>Playground</h3><p>Check a program and read the C. Compile stays on this machine.</p><a href="/playground">Try it</a></article>
60
+ <article class="card"><h3>Examples</h3><p>Counter, ledger, vault, and escrow.</p><a href="/playground">Open an example</a></article>
61
+ </div>
62
+ <p class="note">This is not a published package and not a token. Version 0.1.0. Compute-unit comparisons against Anchor are not claimed here.</p>
63
+ </div>
64
+ <footer>Python blue and yellow. Solana mint and purple are accents. Light theme only.</footer>
65
+ </body>
66
+ </html>