micropip icon indicating copy to clipboard operation
micropip copied to clipboard

Download `pyodide-lock.json` with results of micropip.freeze()

Open rth opened this issue 1 year ago • 2 comments

micropip.freeze() returns the pyodide-lock.json contents, and it would be nice if there was some convenience function that would trigger the download of such pyodide-lock.json.

Maybe something like,

def download_pyodide_lock():
    from js import document, Blob, URL

    blob = Blob.new([micropip.freeze()], {"type": "application/json;charset=utf-8"})
    a = document.createElement("a")
    a.href = URL.createObjectURL(blob)
    a.download = "pyodide-lock.json"
    document.body.appendChild(a)
    a.click()
    document.body.removeChild(a)

Though it wouldn't work in a web-worker (and JupyterLite)

rth avatar Jun 23 '23 11:06 rth