extension_migration_2_3.rst 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .. _extension_migration_2_3:
  2. JupyterLab 2.x to 3.x Extension Migration Guide
  3. ------------------------------------------------
  4. This is a migration guide for updating extensions that support JupyterLab 2.x to work in JupyterLab 3.x.
  5. Upgrading Library Versions
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. JupyterLab 3.0 provides a script to upgrade an existing extension to use the new extension system and packaging.
  8. First, make sure to update to JupyterLab 3.0 with ``pip``:
  9. .. code:: bash
  10. pip install jupyterlab -U
  11. Or with ``conda``:
  12. .. code:: bash
  13. conda install -c conda-forge jupyterlab=3
  14. Then at the root folder of the extension, run:
  15. .. code:: bash
  16. python -m jupyterlab.upgrade_extension .
  17. The upgrade script creates the necessary files for packaging the JupyterLab extension as a Python package, such as
  18. ``setup.py`` and ``pyproject.toml``.
  19. The upgrade script also updates the dependencies in ``package.json`` to the ``^3.0.0`` packages. Here is an example diff:
  20. .. code:: diff
  21. index 6f1562f..3fcdf37 100644
  22. --- a/package.json
  23. +++ b/package.json
  24. @@ -29,9 +29,13 @@
  25. "scripts": {
  26. - "build": "tsc",
  27. - "build:labextension": "npm run clean:labextension && mkdirp myextension/labextension && cd myextension/labextension && npm pack ../..",
  28. - "clean": "rimraf lib tsconfig.tsbuildinfo",
  29. + "build": "jlpm run build:lib && jlpm run build:labextension:dev",
  30. + "build:prod": "jlpm run build:lib && jlpm run build:labextension",
  31. + "build:lib": "tsc",
  32. + "build:labextension": "jupyter labextension build .",
  33. + "build:labextension:dev": "jupyter labextension build --development True .",
  34. + "clean": "rimraf lib tsconfig.tsbuildinfo myextension/labextension",
  35. + "clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
  36. "clean:labextension": "rimraf myextension/labextension",
  37. "eslint": "eslint . --ext .ts,.tsx --fix",
  38. "eslint:check": "eslint . --ext .ts,.tsx",
  39. @@ -59,12 +63,12 @@
  40. ]
  41. },
  42. "dependencies": {
  43. - "@jupyterlab/application": "^2.0.0",
  44. - "@jupyterlab/apputils": "^2.0.0",
  45. - "@jupyterlab/observables": "^3.0.0",
  46. + "@jupyterlab/builder": "^3.0.0",
  47. + "@jupyterlab/application": "^3.0.0",
  48. + "@jupyterlab/apputils": "^3.0.0",
  49. + "@jupyterlab/observables": "^3.0.0",
  50. "@lumino/algorithm": "^1.2.3",
  51. "@lumino/commands": "^1.10.1",
  52. "@lumino/disposable": "^1.3.5",
  53. @@ -99,6 +103,13 @@
  54. - "typescript": "~3.8.3"
  55. + "typescript": "~4.0.1"
  56. },
  57. "jupyterlab": {
  58. - "extension": "lib/plugin"
  59. + "extension": "lib/plugin",
  60. + "outputDir": "myextension/labextension/"
  61. }
  62. }
  63. On the diff above, we see that additional development scripts are also added, as they are used by the new extension system workflow.
  64. Publishing the extension to PyPI and conda-forge
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. TODO