@@ -157,6 +157,112 @@ not like to share between Pixi and rattler-build.
157157 ...
158158 ```
159159
160+ ### Pyodide
161+ !!! note
162+
163+ Mirror configuration requires Pyodide version 0.28.0 or later.
164+ [ Pyodide] [ 10 ] Python distribution, wheels and JavaScript/WebAssembly runtime are
165+ all available in Mahoraga. To enable them, add the following line to your
166+ ` mahoraga.toml ` :
167+ ``` toml title="mahoraga.toml" hl_lines="3"
168+ [cors ]
169+ allow-origins = [
170+ " *" ,
171+ ]
172+ ```
173+ The frontend configuration depends on the library you directly use:
174+ === "Pyodide"
175+
176+ ``` html hl_lines="6 13-22 24"
177+ <!doctype html>
178+ <html>
179+ <head>
180+ <meta charset="UTF-8">
181+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
182+ <script type="text/javascript" src="http://127.0.0.1:3450/pyodide/v0.28.0/full/pyodide.js"></script>
183+ </head>
184+ <body>
185+ <script type="text/javascript">
186+ async function main() {
187+ let pyodide = await loadPyodide();
188+ await pyodide.loadPackage("micropip");
189+ // Prefer Pyodide-maintained wheels over PyPI ones
190+ // If this is not desired, remove the following lines
191+ pyodide.runPython(`
192+ import micropip
193+ class _Transaction(micropip.transaction.Transaction):
194+ def __post_init__(self):
195+ super().__post_init__()
196+ self.search_pyodide_lock_first = True
197+ micropip.package_manager.Transaction = _Transaction
198+ `);
199+ const micropip = pyodide.pyimport("micropip");
200+ micropip.set_index_urls("http://127.0.0.1:3450/pypi/simple/{package_name}/?micropip=1");
201+ await micropip.install(["your_package"]);
202+ pyodide.runPython(`# Your Python code here`);
203+ }
204+ main();
205+ </script>
206+ </body>
207+ </html>
208+ ```
209+
210+ === "PyScript"
211+
212+ ``` html hl_lines="6 7 11 12"
213+ <!doctype html>
214+ <html>
215+ <head>
216+ <meta charset="UTF-8">
217+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
218+ <script type="module" src="http://127.0.0.1:3450/npm/@pyscript/core@0/dist/core.js"></script>
219+ <link rel="stylesheet" href="http://127.0.0.1:3450/npm/@pyscript/core@0/dist/core.css">
220+ </head>
221+ <body>
222+ <script type="py" config='{
223+ "index_urls": ["http://127.0.0.1:3450/pypi/simple/{package_name}/?micropip=1"],
224+ "interpreter": "http://127.0.0.1:3450/pyodide/v0.28.0/full/pyodide.mjs",
225+ "packages": ["your_package"]
226+ }'># Your Python code here</script>
227+ </body>
228+ </html>
229+ ```
230+
231+ === "Stlite"
232+
233+ ``` html hl_lines="6 11 14 16-19"
234+ <!doctype html>
235+ <html>
236+ <head>
237+ <meta charset="UTF-8">
238+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
239+ <link rel="stylesheet" href="http://127.0.0.1:3450/npm/@stlite/browser@0/build/stlite.css">
240+ </head>
241+ <body>
242+ <div id="root"></div>
243+ <script type="module">
244+ import { mount } from "http://127.0.0.1:3450/npm/@stlite/browser@0/build/stlite.js";
245+ mount(
246+ {
247+ pyodideUrl: "http://127.0.0.1:3450/pyodide/v{{ pyodide_py_version }}/full/pyodide.js",
248+ requirements: [
249+ // Stlite doesn't expose the `index_urls` option,
250+ // hence the absolute wheel urls here
251+ "http://127.0.0.1:3450/pypi/packages/py3/b/blinker/blinker-{{ blinker_version }}-py3-none-any.whl",
252+ "http://127.0.0.1:3450/pypi/packages/py3/t/tenacity/tenacity-{{ tenacity_version }}-py3-none-any.whl",
253+ ],
254+ entrypoint: "your_app.py",
255+ files: {
256+ "your_app.py": `# Your Python code here`,
257+ },
258+ },
259+ document.getElementById("root"),
260+ );
261+ </script>
262+ </body>
263+ </html>
264+ ```
265+
160266### pymanager
161267The next generation of the official Python installer for Windows,
162268[ pymanager] [ 4 ] , can be downloaded from Mahoraga:
@@ -186,3 +292,4 @@ The next generation of the official Python installer for Windows,
186292[ 7 ] : #server-configuration
187293[ 8 ] : https://rattler.build/latest/
188294[ 9 ] : #pixi
295+ [ 10 ] : https://pyodide.org/en/stable/
0 commit comments