Thanks for the advice. I decided to opt for having a single code base that I develop in JupyterLab 3 and then consolidate all API changes in a single file compatibility.ts
.
After testing out that same code in my JupyterLab extension based on JupyterLab 3.x and my other extension based on JupyterLab 4.x, it works fine. To do this I simply copy/pasted the source code of my extension in both extension repositories and tested it out. My problem is that I’m not completely sure as to how I should adapt the package.json, the pyproject.toml, and any other files in order for this JupyterLab 3.x extension built package to work fine in JupyterLab >= 3.x, hence me first trying the same code in two different extensions. However, I know that I have to take care of modifying dependencies since when I build the extension package from JupyterLab 3.x and install it in a fresh JupyterLab 4.x environment I get some errors such as :
Unsatisfied version 4.0.0 from @jupyterlab/application-top of shared singleton module @jupyterlab/settingregistry (required ^3.5.3)
Unsatisfied version 2.1.1 from @jupyterlab/application-top of shared singleton module @lumino/signaling (required ^1.10.0)
in my developer console upon JupyterLab start-up. My extension is still activated, but all the features that rely on the settingregistry
don’t work.
@bollwyvl @parmentelat could you provide me with some guidance with what files (any other than package.json
& pyproject.toml
?) I should adapt and what dependencies I should make sure I modify in my extension repository so I can keep developing my extension in Jupyterlab 3 and have JupyterLab 4 users install and use it without problems ?
Here are the dependencies of my package.json
:
"dependencies": {
"@jupyterlab/application": "^4.0.0",
"@jupyterlab/settingregistry": "^4.0.0"
},
"devDependencies": {
"@jupyterlab/builder": "^3.5.3 || ^4.0.0",
"@jupyterlab/testutils": "^4.0.0",
"@types/jest": "^29.2.0",
"@types/json-schema": "^7.0.11",
"@types/react": "^18.0.26",
"@types/uuid": "^9.0.3",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"css-loader": "^6.7.1",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.7",
"rimraf": "^4.4.1",
"source-map-loader": "^1.0.2",
"style-loader": "^3.3.1",
"stylelint": "^14.9.1",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-recommended": "^8.0.0",
"stylelint-config-standard": "^26.0.0",
"stylelint-prettier": "^2.0.0",
"typescript": "~5.0.2",
"yjs": "^13.5.0"
},
Here is my pyproject.toml
:
[build-system]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version"]
build-backend = "hatchling.build"
[project]
name = "send_3_test"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.8"
classifiers = [
"Framework :: Jupyter",
"Framework :: Jupyter :: JupyterLab",
"Framework :: Jupyter :: JupyterLab :: 4",
"Framework :: Jupyter :: JupyterLab :: Extensions",
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
]
dynamic = ["version", "description", "authors", "urls", "keywords"]
[tool.hatch.version]
source = "nodejs"
[tool.hatch.metadata.hooks.nodejs]
fields = ["description", "authors", "urls"]
[tool.hatch.build.targets.sdist]
artifacts = ["send_3_test/labextension"]
exclude = [".github", "binder"]
[tool.hatch.build.targets.wheel.shared-data]
"send_3_test/labextension" = "share/jupyter/labextensions/send-3-test"
"install.json" = "share/jupyter/labextensions/send-3-test/install.json"
[tool.hatch.build.hooks.version]
path = "send_3_test/_version.py"
[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"send_3_test/labextension/static/style.js",
"send_3_test/labextension/package.json",
]
skip-if-exists = ["send_3_test/labextension/static/style.js"]
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
npm = ["jlpm"]
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
build_cmd = "install:extension"
npm = ["jlpm"]
source_dir = "src"
build_dir = "send_3_test/labextension"
[tool.jupyter-releaser.options]
version_cmd = "hatch version"
[tool.jupyter-releaser.hooks]
before-build-npm = [
"python -m pip install 'jupyterlab>=4.0.0,<5'",
"jlpm",
"jlpm build:prod"
]
before-build-python = ["jlpm clean:all"]
[tool.check-wheel-contents]
ignore = ["W002"]