ipywidgets
ipywidgets copied to clipboard
Ability to specify the NPM package name
My jupyter widget is named buckaroo. I have buckaroo on pypi, however buckaroo is taken on NPM. This wasn't an issue until I tried to install buckaroo inside of a VS Code notebook with the [Jupyter Renderer](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter-renderers plugin). That plugin downloads the package from unpkg http site which is based on NPM. Since I don't own the NPM package name for buckaroo, I can't fix this.
I don't see where in the widget config that the package name needs to be the same as the python package name, and I don't see a lever to change this. I'm not even certain if this is an ipywidgets bug, jupyter extension manager bug, or jupyter renderer bug.
Any help would be appreciated.
For the unkpg route, an extension indeed needs:
- to own a package on
npmjs.org - be published with all of the built assets exported from the
mainentry point in itspackage.json
This name doesn't have to coincide in any way with the python module name, but it is usually convenient if they have some commonality.
The backend class needs to know this canonical name, and export in the _*_module traits. A convenient approach to this is to have this metadata in a base class from which all other widgets in that package inherit, as core does:
NPM_NAME = "@paddymul/buckaroo"
NPM_SEMVER_SPEC = "^0.1.0"
class BuckarooWidget):
_model_module = Unicode(NPM_NAME).tag(sync=True)
_model_module_version = Unicode(NPM_SEMVER_SPEC).tag(sync=True)
_view_module = Unicode(NPM_NAME).tag(sync=True)
_view_module_version = Unicode(NPM_SEMVER_SPEC).tag(sync=True)
class Buckaroo(Basearoo):
_view_name = Unicode('BuckarooView').tag(sync=True)
_model_name = Unicode('BuckarooModel').tag(sync=True)