Skip to content
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

Enable jupyter labextension build/watch to work for custom jupyterlab distributions #9697

Merged
merged 3 commits into from Feb 17, 2021

Conversation

jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Jan 28, 2021

References

Code changes

Currently, jupyter labextension build/watch only work for building prebuilt extensions for core jupyterlab itself. For example, the federated example directly calls the npm builder itself, and cannot use jupyter labextension build because it is pointing to the wrong core package.json file.

This adds an option to jupyter labextension build/watch to give the core package directory. If a custom JupyterLab app follows the same conventions in its package.json metadata, you can prebuild extensions for it by pointing to its package directory with --core-path: jupyter labextension build --core-path=/my/custom/jlab/package /my/extension/to/build

I still left the example using the npm package builder by default to show how it can be done if you have access to the appropriate package.json.

User-facing changes

Backwards-incompatible changes

… distributions.

Currently, jupyter labextension build/watch only work for building prebuilt extensions for core jupyterlab itself. For example, the federated example directly calls the npm builder itself, and cannot use jupyter labextension build because it is pointing to the wrong core file.

This adds an option to jupyter labextension build/watch to give the core package directory. If a custom JupyterLab app follows the same conventions in its package.json metadata, you can prebuild extensions for it by pointing to its package directory with --core-path.
@jasongrout jasongrout added this to the 3.0 milestone Jan 28, 2021
@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio
Copy link
Member

jtpio commented Jan 29, 2021

Nice, thanks!

Wondering what the best way would be for extension authors to target several distributions at once? For example both JupyterLab and JupyterLab Classic? For now they can use the default JupyterLab core path.

Should they produce two bundles / extensions, built with different -core-path?

@jasongrout
Copy link
Contributor Author

Should they produce two bundles / extensions, built with different -core-path?

To be safest, yes, and they should install those two different bundles into different share directories, and the jupyter classic should load its extensions from this other directory by overloading the labextension_path.

The issue here is that core packages are not imported into a prebuilt extension, but if classic has a different set of core packages (in particular a more limited set), a plugin may not include a package that it needs.

And really, we still need to address different versions of jlab, which also count as different distributions.

@jtpio
Copy link
Member

jtpio commented Jan 30, 2021

To be safest, yes, and they should install those two different bundles into different share directories, and the jupyter classic should load its extensions from this other directory by overloading the labextension_path.

Right, although it would be quite convenient to be able to load the same set of JupyterLab extensions automatically, without having extension authors to do extra work.

Otherwise, alternative distributions would probably have to document this in their extension developer guide, and mention how to make an extension compatible with JupyterLab and the other distribution (for example by documenting how to create two bundles and distribute them under share/labextensions/ and share/alternative_labextensions with data_files)

@jtpio
Copy link
Member

jtpio commented Jan 30, 2021

you can prebuild extensions for it by pointing to its package directory with --core-path: jupyter labextension build --core-path=/my/custom/jlab/package /my/extension/to/build

Should we also add a command using the --core-path option to the usage tests, similar to this?

jupyter labextension build extension --static-url /foo/

(just to cover the use of --core-path)

@jasongrout
Copy link
Contributor Author

Should we also add a command using the --core-path option to the usage tests, similar to this?

Done!

@jasongrout
Copy link
Contributor Author

@jtpio, @blink1073 - pinging for final review and/or merge. I think I've addressed everything asked for.

@jtpio
Copy link
Member

jtpio commented Feb 17, 2021

Thanks!

@jtpio jtpio merged commit ce8dc5c into jupyterlab:master Feb 17, 2021
@jtpio
Copy link
Member

jtpio commented Feb 17, 2021

@meeseeksdev please backport to 3.0.x

@jasongrout
Copy link
Contributor Author

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
maintenance status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants