Skip to content

Commit

Permalink
Try to fix makelock discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Feb 13, 2025
1 parent 0b033f7 commit 33a0f5f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ jobs:
- name: Extract the PyPi-enabled pyodide-lock.json
run: |
cp files/requirements.txt pyodide/my-requirements.txt
pyodide/run_docker --non-interactive node tools/makelock.mjs my-requirements.txt dist/pypi-pyodide-lock.json
cp tools/makelock.mjs pyodide/makelock.mjs
pyodide/run_docker --non-interactive node makelock.mjs my-requirements.txt dist/pypi-pyodide-lock.json
rm pyodide/makelock.mjs
rm pyodide/my-requirements.txt
- name: Clean up the pyodide build
run: |
Expand Down
2 changes: 1 addition & 1 deletion pyodide
Submodule pyodide updated 1 files
+0 −32 tools/makelock.mjs
32 changes: 32 additions & 0 deletions tools/makelock.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { readFileSync, writeFileSync } from "fs";
import { argv } from "process";

import { loadPyodide } from "dist/pyodide.mjs";

const [_node_path, _script_path, requirements_path, new_lockfile_path] = argv;

const requirements = readFileSync(requirements_path, { encoding: 'utf8' });

const py = await loadPyodide({ packages: ["micropip"] });

await py.runPythonAsync(`
import micropip
micropip.set_index_urls([
# TODO: use a locally-hosted index with the fresh wheels
"https://lab.climet.eu/main/pypa/simple/{package_name}/",
"https://pypi.org/pypi/{package_name}/json",
])
await micropip.install([
r for r in """${requirements}""".splitlines()
if len(r) > 0 and not r.startswith('#')
], verbose=True)
with open("/pyodide-lock.json", "w") as f:
f.write(micropip.freeze())
`);

const lock = py.FS.readFile("/pyodide-lock.json", { encoding: 'utf8' });

writeFileSync(new_lockfile_path, lock);

0 comments on commit 33a0f5f

Please sign in to comment.