Skip to content

Allow customizing the lockFileURL with a query parameter #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

juntyr
Copy link
Contributor

@juntyr juntyr commented Feb 7, 2025

Custom pyodide-lock.json URLs provide an easy way to customize the Pyodide kernel. At the moment, you can only statically change it in the Pyodide config. With this PR, it would be possible to provide the URL as a ?pyodide-kernel-lock-file-url=... query parameter. This should be a sufficient MVP to allow experimenting with custom kernels, from which we could later design a more user-friendly interface.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

lite-badge 👈 Try it on ReadTheDocs

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 7, 2025

As mentioned on the issue about offering multiple kernelspecs: I don't see how how this would make the situation more predictable. Further, once very public API features like this get added, they get very hard to take away or change, as "it broke my WordPress integration that hot links to your docs site" or whatever.

As usual: the recommended approach to adding more features like this would be a separate extension or kernel.

@juntyr
Copy link
Contributor Author

juntyr commented Feb 7, 2025

I’d be happy with any approach that can provide dynamically selected Pyodide configs, right now I just need to change the lock file URL. Lock files have the advantage that they are fully resolved and my use case is about preventing dependency drift.

I’m not sure how an extension could help here without duplicating the entire Pyodide kernel. Are there some existing hooks for how another extension could change the launch params for a fresh kernel at runtime?

@juntyr
Copy link
Contributor Author

juntyr commented Feb 13, 2025

I published an extension, https://github.com/juntyr/a-jupyterlite-query-config, that allows you to enable overriding any (config-allowed) config with URL query params. To use,

requirements.txt for the JupyterLite build:

# JupyterLite: override config settings with URL query parameters
a-jupyterlite-query-config~=0.1.0

jupyter-lite.json:

{
    "jupyter-lite-schema-version": 0,
    "jupyter-config-data": {
        "litePluginSettings": {
            "a-jupyterlite-query-config:plugin": {
                "overrides": {
                    "pyodideKernelLockFileURL": "litePluginSettings.@jupyterlite/pyodide-kernel-extension:kernel.loadPyodideOptions.lockFileURL",
                    "pyodideKernelPackages": "litePluginSettings.@jupyterlite/pyodide-kernel-extension:kernel.loadPyodideOptions.packages"
                }
            }
        }
    }
}

to allow overriding the lock file URL with ?pyodideKernelLockFileURL="URL" and the package preload list with ?pyodideKernelLockFileURL=["PACKAGE"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants