Skip to content

Commit 63f2c35

Browse files
committed
use latest widget template + upgrade idom
1 parent 0a930c5 commit 63f2c35

File tree

23 files changed

+2229
-1203
lines changed

23 files changed

+2229
-1203
lines changed

.gitignore

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.egg-info/
2+
.ipynb_checkpoints/
23
dist/
34
build/
45
*.py[cod]
@@ -11,13 +12,6 @@ idom_jupyter/labextension/
1112
# OS X
1213
.DS_Store
1314

14-
# Py Env
15+
# Python
1516
venv
16-
.python-version
17-
18-
# VSCode
19-
.vscode
20-
21-
# Jupyter
22-
.ipynb_checkpoints/
2317
Untitled*.ipynb

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include idom-client-jupyter.json
99

1010
include LICENSE
1111
include setup.py
12+
include setup.cfg
1213
include pyproject.toml
1314
include install.json
1415

README.md

Lines changed: 12 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,28 @@
11
# idom-jupyter
22

3-
A client for [IDOM](https://github.com/idom-team/idom) implemented using Jupyter widgets
3+
A client for IDOM implemented using Jupyter widgets
44

5-
## Try It Now!
5+
## Installation
66

7-
Check out a live example by clicking the badge below:
7+
To install use pip:
88

9-
<a href="https://mybinder.org/v2/gh/idom-team/idom-jupyter/main?filepath=notebooks%2Fintroduction.ipynb">
10-
<img alt="Binder" height="25px" src="https://mybinder.org/badge_logo.svg" />
11-
</a>
12-
13-
## Getting Started
14-
15-
To install use `pip`:
16-
17-
```
18-
pip install idom_jupyter
19-
```
20-
21-
Then, before anything else, do one of the following:
22-
23-
1. At the top of your notebook run
24-
25-
```python
26-
import idom_jupyter
27-
```
28-
29-
2. Register `idom_jupyter` as a permanant IPython extension in [your config file](https://ipython.readthedocs.io/en/stable/config/intro.html#introduction-to-ipython-configuration):
30-
31-
```python
32-
c.InteractiveShellApp.extensions = [
33-
'idom_jupyter'
34-
]
35-
```
36-
37-
## Usage
38-
39-
Once you're done [getting started](#getting-started), you can author and display IDOM
40-
layouts natively in your Jupyter Notebook:
41-
42-
```python
43-
import idom
44-
45-
@idom.component
46-
def ClickCount():
47-
count, set_count = idom.hooks.use_state(0)
48-
return idom.html.button(
49-
{"onClick": lambda event: set_count(count + 1)},
50-
[f"Click count: {count}"],
51-
)
52-
53-
ClickCount()
54-
```
55-
56-
You can also turn an `idom` element constructor into one that returns an `ipywidget` with
57-
the `idom_juptyer.widgetize` function. This is useful if you wish to use IDOM in combination
58-
with other Jupyter Widgets as in the following example:
59-
60-
```python
61-
ClickCountWidget = idom_jupyter.widgetize(ClickCount)
62-
ipywidgets.Box(
63-
[
64-
ClickCountWidget(),
65-
ClickCountWidget(),
66-
]
67-
)
68-
```
69-
70-
Alternatively just wrap an `idom` element instance in an `idom_jupyter.LayoutWidget`:
71-
72-
```python
73-
ipywidgets.Box(
74-
[
75-
idom_jupyter.LayoutWidget(ClickCount()),
76-
idom_jupyter.LayoutWidget(ClickCount()),
77-
]
78-
)
79-
```
80-
81-
# Development Installation
9+
$ pip install idom_jupyter
8210

8311
For a development installation (requires [Node.js](https://nodejs.org) and [Yarn version 1](https://classic.yarnpkg.com/)),
8412

85-
```
86-
git clone https://github.com/idom-team/idom-jupyter.git
87-
cd idom-jupyter
88-
pip install -e . -r requirements.txt
89-
jupyter nbextension install --py --symlink --overwrite --sys-prefix idom_jupyter
90-
jupyter nbextension enable --py --sys-prefix idom_jupyter
91-
```
13+
$ git clone https://github.com/idom-team/idom-jupyter.git
14+
$ cd idom-jupyter
15+
$ pip install -e .
16+
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix idom_jupyter
17+
$ jupyter nbextension enable --py --sys-prefix idom_jupyter
9218

9319
When actively developing your extension for JupyterLab, run the command:
9420

95-
```
96-
jupyter labextension develop --overwrite idom_jupyter
97-
```
21+
$ jupyter labextension develop --overwrite idom_jupyter
9822

9923
Then you need to rebuild the JS when you make a code change:
10024

101-
```
102-
cd js
103-
yarn run build
104-
```
25+
$ cd js
26+
$ yarn run build
10527

10628
You then need to refresh the JupyterLab page when your javascript changes.

RELEASE.md

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,53 @@
1-
To release a new version of the idom-jupyter Python library on PyPI:
2-
3-
- Update `_version.py` (set release version, remove 'dev')
4-
- git add the `_version.py` file and git commit
5-
- ```
6-
python setup.py sdist bdist_wheel
7-
twine upload dist/*
8-
git tag -a X.X.X -m 'comment'
9-
git add and git commit
10-
git push
11-
git push --tags
12-
```
13-
14-
To release a new version of idom-client-jupyter on NPM:
15-
16-
- Update `js/package.json` with new npm package version
17-
- Update the following attributes on your widget implementations in the Python and Javascript packages:
18-
- `_view_module_version`
19-
- `_model_module_version`
20-
- ```
21-
# clean out the `dist` and `node_modules` directories
22-
git clean -fdx
23-
npm install
24-
npm publish
25-
```
1+
# Release
2+
3+
Before doing a release, check to see if there are any outstanding changes or untracked files:
4+
5+
```
6+
git status
7+
git clean -fdxn
8+
```
9+
10+
Commit changes, and make sure that any untracked files can be deleted. Then clean the repository:
11+
12+
```
13+
git clean -fdx # actually delete untracked files
14+
```
15+
16+
## Javascript release
17+
18+
To release a new version of idom-client-jupyter on NPM, first register for an NPM account [here](https://www.npmjs.com/), then log in with `yarn login`. Then:
19+
20+
1. Update `js/package.json` with the new npm package version
21+
2. Build and publish the npm package inside the `js/` directory:
22+
23+
```
24+
cd js/
25+
yarn install
26+
yarn publish
27+
cd ..
28+
```
29+
30+
## Python release
31+
32+
To release a new version of idom_jupyter on PyPI, first make sure that the `build` package is installed: `pip install build`.
33+
34+
1. Update `idom_jupyter/_version.py`:
35+
- Update `__version__`
36+
- Update `NPM_PACKAGE_RANGE` if necessary
37+
2. Commit changes to `_version.py` and tag the release
38+
```
39+
git add idom_jupyter/_version.py
40+
git tag -a X.X.X -m 'comment'
41+
```
42+
3. Generate Python packages and upload to PyPI:
43+
```
44+
python -m build
45+
twine check dist/*
46+
twine upload dist/*
47+
```
48+
4. Update `_version.py` (add 'dev' and increment minor)
49+
```
50+
git commit -a -m 'Back to dev'
51+
git push
52+
git push --tags
53+
```

install.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"packageManager": "python",
33
"packageName": "idom_jupyter",
44
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package idom_jupyter"
5-
}
5+
}

js/amd-public-path.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// In an AMD module, we set the public path using the magic requirejs 'module' dependency
2+
// See https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module
3+
// Since 'module' is a requirejs magic module, we must include 'module' in the webpack externals configuration.
4+
import * as module from 'module';
5+
const url = new URL(module.uri, document.location)
6+
// Using lastIndexOf('/')+1 gives us the empty string if there is no '/', so pathname becomes '/'
7+
url.pathname = url.pathname.slice(0,url.pathname.lastIndexOf('/')+1);
8+
__webpack_public_path__ = `${url.origin}${url.pathname}`;

js/lib/embed.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

js/lib/extension.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
// This file contains the javascript that is run when the notebook is loaded.
22
// It contains some requirejs configuration and the `load_ipython_extension`
33
// which is required for any notebook extension.
4-
//
5-
// Some static assets may be required by the custom widget javascript. The base
6-
// url for the notebook is not known at build time and is therefore computed
7-
// dynamically.
8-
__webpack_public_path__ =
9-
document.querySelector("body").getAttribute("data-base-url") +
10-
"nbextensions/idom-client-jupyter";
114

125
// Configure requirejs
136
if (window.require) {
@@ -20,7 +13,4 @@ if (window.require) {
2013
});
2114
}
2215

23-
// Export the required load_ipython_extension
24-
module.exports = {
25-
load_ipython_extension: function () {},
26-
};
16+
export function load_ipython_extension() {}

0 commit comments

Comments
 (0)