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

Distribute the extensions as Python packages #243

Merged
merged 20 commits into from
Mar 11, 2021

Conversation

jtpio
Copy link
Member

@jtpio jtpio commented Mar 1, 2021

Fixes #235

This takes the approach of packaging all the extension at once into a jupyterlab-renderers package.

~So a pip install jupyterlab-renderers will install all the extensions.`

Edit: Each extension is distributed as its own Python package.

JupyterLab v3.0.9
/home/username/miniforge3/envs/jupyter-renderers/share/jupyter/labextensions
        @jupyterlab/katex-extension v3.1.0 enabled OK (python, jupyterlab-renderers)
        @jupyterlab/vega2-extension v3.0.0 enabled OK (python, jupyterlab-renderers)
        @jupyterlab/mathjax3-extension v4.1.1 enabled OK (python, jupyterlab-renderers)
        @jupyterlab/fasta-extension v3.0.0 enabled OK (python, jupyterlab-renderers)
        @jupyterlab/geojson-extension v3.0.0 enabled OK (python, jupyterlab-renderers)
        @jupyterlab/vega3-extension v3.0.0 enabled OK (python, jupyterlab-renderers)

TODO

  • Start with @jupyterlab/fasta-extension
  • Package the other extensions
  • Check if the jupyter labextension develop script can be used with multiple packages and this setup
  • Rebase once Switch to GitHub Actions on CI #242 is merged to pick up the GitHub Actions workflow and build from it
  • Update CI workflow to install via pip
  • Update dev setup and READMEs
  • Update the individual READMEs

@jtpio
Copy link
Member Author

jtpio commented Mar 1, 2021

Check if the jupyter labextension develop script can be used with multiple packages and this setup

The develop script might need another pass to support the setup of 1 Python package for multiple lab extensions:

$ jupyter labextension develop . --overwrite
Installing /path/to/repo/jupyter-renderers/jupyterlab-renderers/labextension/@jupyterlab/fasta-extension -> @jupyterlab/fasta-extension
Building extension in /path/to/repo/jupyter-renderers/jupyterlab-renderers
An error occured.
FileNotFoundError: [Errno 2] No such file or directory: '/path/to/repo/jupyter-renderers/jupyterlab-renderers/package.json'
See the log file for details:  /tmp/jupyterlab-debug-mn3dgl19.log

@jasongrout
Copy link
Contributor

jasongrout commented Mar 3, 2021

Some of these are alternatives that don't make sense to install together. For example, it doesn't make sense to install both mathjax 3 and katex as they stomp on each other to be the builtin math renderer (and disable the builtin mathjax 2 renderer).

I was thinking about this when upgrading to jlab 3, and how we make prebuilt extensions. I think we can either have multiple python packages in this repo, or split things out to multiple repos (which I think would make updates and maintenance onerous). I would suggest multiple python packages in this repo over splitting things out into multiple repos, at least as a first experiment.

@jtpio
Copy link
Member Author

jtpio commented Mar 3, 2021

I would suggest multiple python packages in this repo over splitting things out into multiple repos, at least as a first experiment.

Right. This sounds like we will end up with a "Python monorepo", so this might add some complexity especially if we want to keep some files like setup.py in sync (similar for all the extensions). But maybe there is a way to streamline the setup so it's convenient to work with.

Agree it's still better than maintaining multiple repos 👍

@jtpio
Copy link
Member Author

jtpio commented Mar 3, 2021

Python monorepo

The closest we have to this for now is probably the Extension Examples repo: https://github.com/jupyterlab/extension-examples

@jtpio jtpio force-pushed the packaging branch 3 times, most recently from 597bd0d to 68cba44 Compare March 4, 2021 17:19
@jtpio
Copy link
Member Author

jtpio commented Mar 5, 2021

So the repo is now a collection of Python packages.

Each of the extensions was updated using the upgrade script:

python -m jupyterlab.upgrade_extension .

Check if the jupyter labextension develop script can be used with multiple packages and this setup

The develop script can be run manually in each folder now.

@jtpio jtpio changed the title Package the extensions into a Python package Distribute the extensions as Python packages Mar 5, 2021
@jtpio jtpio marked this pull request as ready for review March 5, 2021 10:29
"outDir": "lib",
"rootDir": "src",
"lib": ["es2015", "dom"]
"skipLibCheck": true,
Copy link
Member Author

Choose a reason for hiding this comment

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

skipLibCheck wasn't originally used, but updating the dependencies led to TS compile errors for what looks like conflict with the underlying vega-lite dependency:

https://github.com/jupyterlab/jupyter-renderers/runs/2033195852

node_modules/vega-lite/build/src/compile/selection/selection.d.ts(11,10): error TS2440: Import declaration conflicts with local declaration of 'SelectionComponent'.
  node_modules/vega-lite/build/src/log.d.ts(23,5): error TS2416: Property 'level' in type 'LocalLogger' is not assignable to the same property in base type 'LoggerInterface'.
    Type '() => this' is not assignable to type '{ (_: number): this; (): number; }'.
      Type 'this' is not assignable to type 'number'.
        Type 'LocalLogger' is not assignable to type 'number'.

So leaving skipLibCheck: true to make it simpler for now since Vega 3 is deprecated.

@jtpio
Copy link
Member Author

jtpio commented Mar 5, 2021

So the repo is now a collection of Python packages.

Keeping the packages folder structure and the lerna setup for now. This makes it possible to use the previous monorepo workflow for example to install dependencies with jlpm and build everything at once with jlpm run build.

Copy link
Contributor

@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! Needs a rebase for the yarn lock.

@jasongrout
Copy link
Contributor

Thanks!

@jasongrout jasongrout merged commit 8237e65 into jupyterlab:master Mar 11, 2021
@jasongrout
Copy link
Contributor

I've published these python packages, and added you, @jtpio as a publisher as well on pypi.

@jasongrout
Copy link
Contributor

I guess next up is making conda-forge feedstocks, if we want to go that far?

@jtpio
Copy link
Member Author

jtpio commented Mar 12, 2021

Perfect, thanks!

I guess next up is making conda-forge feedstocks, if we want to go that far?

Probably yes. Maybe it's possible to generate most of the recipes with grayskull and submit a single PR to add them all at once.

@jtpio jtpio deleted the packaging branch March 12, 2021 08:00
@jtpio
Copy link
Member Author

jtpio commented Mar 12, 2021

Opened conda-forge/staged-recipes#14245. Recipes were generated with:

grayskull pypi jupyterlab-fasta jupyterlab-geojson jupyterlab-katex jupyterlab-mathjax3 jupyterlab-vega2 jupyterlab-vega3

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.

Package into a python extension
3 participants