Skip to content

Commit a4a0599

Browse files
Revive: Enable Python API in the JupyterLite deployment + jupytercad-lite metapackage (#687)
* Enable Python API in the JupyterLite deployment (#680) * Config docs * Revert changes * Update lite env * update lite config * Bump yjs-widgets and make changes wrt * Update lite/environment.yml Co-authored-by: martinRenou <[email protected]> * bump yjs-widgets on jupytercad_app too * use updated version of actions/cache * try building jcad in lite * try installing whl instead from src * try giving a random name to the wheels to be used for lite * correct path * not needed * move collaboration to jupytercad * do same for lab * No need to install * install jupyter-server in CI * typo * lazily import `setup_handlers` * install jupytercad metapackage for ui tests * install metapackage in correct job * build jupytercad metapackage too * try adding docprovider to sharedPackages * not needed * try bundled true --------- Co-authored-by: martinRenou <[email protected]> * Add `jupytercad_lite` metapackage (#681) * Add `jupytercad_lite` metapackage * update bump-version * port remaining changes * install jupytercad_lite on build-lite job * install jupytercad_lite on build-lite job * try building jupytercad_lite in build packages * continue installing the labextension in the dev install script * continue installing the package too * install metapackage outside the for loop * condition not needed * Fix: Collaborative model (#682) Fic: Collaborative model --------- Co-authored-by: Arjun Verma <[email protected]>
1 parent 6674ba2 commit a4a0599

File tree

30 files changed

+263
-95
lines changed

30 files changed

+263
-95
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
yarn=3
2626
2727
- name: Setup pip cache
28-
uses: actions/cache@v2
28+
uses: actions/cache@v4
2929
with:
3030
path: ~/.cache/pip
3131
key: pip-3.9-${{ hashFiles('package.json') }}
@@ -38,7 +38,7 @@ jobs:
3838
run: echo "::set-output name=dir::$(yarn cache dir)"
3939

4040
- name: Setup yarn cache
41-
uses: actions/cache@v2
41+
uses: actions/cache@v4
4242
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
4343
with:
4444
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -47,7 +47,7 @@ jobs:
4747
yarn-
4848
4949
- name: Setup OpenCascade build cache
50-
uses: actions/cache@v2
50+
uses: actions/cache@v4
5151
with:
5252
path: |
5353
packages/opencascade/lib/jupytercad.opencascade.js
@@ -84,6 +84,8 @@ jobs:
8484
python/jupytercad_core/dist/jupytercad*
8585
python/jupytercad_lab/dist/jupytercad*
8686
python/jupytercad_app/dist/jupytercad*
87+
python/jupytercad/dist/jupytercad*
88+
python/jupytercad_lite/dist/jupytercad*
8789
if-no-files-found: error
8890

8991
test_isolated:
@@ -148,7 +150,7 @@ jobs:
148150
shell: bash -l {0}
149151
run: |
150152
set -eux
151-
cp ./jupytercad_core/dist/jupytercad*.whl ./jupytercad_lab/dist/jupytercad*.whl ./jupytercad_app/dist/jupytercad*.whl .
153+
cp ./jupytercad_core/dist/jupytercad*.whl ./jupytercad_lab/dist/jupytercad*.whl ./jupytercad_app/dist/jupytercad*.whl ./jupytercad/dist/jupytercad*.whl .
152154
python -m pip install jupytercad*.whl
153155
154156
- name: Install dependencies
@@ -159,7 +161,7 @@ jobs:
159161
run: jlpm install
160162

161163
- name: Set up browser cache
162-
uses: actions/cache@v3
164+
uses: actions/cache@v4
163165
with:
164166
path: |
165167
${{ github.workspace }}/pw-browsers
@@ -221,6 +223,7 @@ jobs:
221223
pip
222224
jupyterlite-core
223225
jupyterlite-xeus
226+
jupyter_server
224227
225228
- name: Download extension package
226229
uses: actions/download-artifact@v4
@@ -231,15 +234,17 @@ jobs:
231234
shell: bash -l {0}
232235
run: |
233236
set -eux
234-
cp ./jupytercad_core/dist/jupytercad*.whl ./jupytercad_lab/dist/jupytercad*.whl ./jupytercad_app/dist/jupytercad*.whl .
235-
python -m pip install jupytercad*.whl
237+
cp ./jupytercad_core/dist/jupytercad*.whl jupytercad_core-0.0.1-py3-none-any.whl
238+
cp ./jupytercad_lab/dist/jupytercad*.whl jupytercad_lab-0.0.1-py3-none-any.whl
239+
cp ./jupytercad_app/dist/jupytercad*.whl jupytercad_app-0.0.1-py3-none-any.whl
240+
cp ./jupytercad_lite/dist/jupytercad*.whl jupytercad_lite-0.0.1-py3-none-any.whl
236241
237242
- name: Build the lite site
238243
shell: bash -l {0}
239244
working-directory: lite
240245
run: |
241246
set -eux
242-
mkdir -p content && cp ../examples/*.jcad ../examples/*.STEP ../examples/*.stl ./content
247+
mkdir -p content && cp ../examples/*.jcad ../examples/*.STEP ../examples/*.stl ../examples/*.ipynb ./content
243248
jupyter lite build --contents content --output-dir dist
244249
245250
- name: Upload github-pages artifact

examples/Notebook.ipynb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,29 @@
1818
},
1919
{
2020
"cell_type": "code",
21-
"execution_count": 10,
21+
"execution_count": 4,
2222
"id": "050e5936-f9e1-44ff-8bc9-a8556d7643ee",
2323
"metadata": {},
24-
"outputs": [],
24+
"outputs": [
25+
{
26+
"ename": "ModuleNotFoundError",
27+
"evalue": "No module named 'jupytercad'",
28+
"output_type": "error",
29+
"traceback": [
30+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
31+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
32+
"Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mjupytercad\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m CadDocument\n",
33+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'jupytercad'"
34+
]
35+
}
36+
],
2537
"source": [
26-
"from jupytercad_lab import CadDocument"
38+
"from jupytercad import CadDocument"
2739
]
2840
},
2941
{
3042
"cell_type": "code",
31-
"execution_count": 11,
43+
"execution_count": 5,
3244
"id": "9821d466-6ae7-418f-aea7-9d67153da7d6",
3345
"metadata": {},
3446
"outputs": [],
@@ -38,22 +50,22 @@
3850
},
3951
{
4052
"cell_type": "code",
41-
"execution_count": 12,
53+
"execution_count": 6,
4254
"id": "e30499f0-6732-4611-a25e-46b27e606b08",
4355
"metadata": {},
4456
"outputs": [
4557
{
4658
"data": {
4759
"application/vnd.jupyter.ywidget-view+json": {
48-
"model_id": "c586b4fc0d474786bd7fbf9635e15421",
60+
"model_id": "c0c9e05d08ec4e71bebc1877eec30531",
4961
"version_major": 2,
5062
"version_minor": 0
5163
},
5264
"text/plain": [
53-
"<jupytercad_lab.notebook.cad_document.CadDocument object at 0x110fc7410>"
65+
"<jupytercad_lab.notebook.cad_document.CadDocument object at 0x108aa4800>"
5466
]
5567
},
56-
"execution_count": 12,
68+
"execution_count": 6,
5769
"metadata": {},
5870
"output_type": "execute_result"
5971
}

lite/environment.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: xeus-python-kernel
22
channels:
3-
- https://repo.mamba.pm/emscripten-forge
4-
- conda-forge
3+
- https://prefix.dev/emscripten-forge-dev
4+
- https://prefix.dev/conda-forge
55
dependencies:
6+
- python=3.13
7+
- pip
68
- xeus-python
9+
- requests
10+
- jupyter_ydoc=2.1.5
11+
- ypywidgets>=0.9.6,<0.10.0
12+
- comm>=0.1.2,<0.2.0
13+
- pydantic>=2,<3
14+
- pip:
15+
- yjs-widgets>=0.4,<0.5
16+
- my-jupyter-shared-drive
17+
- ../jupytercad_core-0.0.1-py3-none-any.whl
18+
- ../jupytercad_lab-0.0.1-py3-none-any.whl
19+
- ../jupytercad_lite-0.0.1-py3-none-any.whl

lite/jupyter-lite.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
{
22
"jupyter-lite-schema-version": 0,
3-
"jupyter-config-data": {
4-
"appName": "My JupyterCAD App",
5-
"disabledExtensions": [
6-
"@jupyter/collaboration-extension",
7-
"@jupyter/docprovider-extension"
8-
]
9-
}
3+
"jupyter-config-data": {}
104
}

packages/base/src/widget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ export class JupyterCadPanel extends SplitPanel {
268268

269269
(this._consoleTracker.widgetAdded as any).emit(consolePanel);
270270
await consolePanel.sessionContext.ready;
271-
await consolePanel.console.inject(
272-
`from jupytercad_lab import CadDocument\ndoc = CadDocument("${jcadPath}")`
273-
);
274271
this.addWidget(this._consoleView);
275272
this.setRelativeSizes([2, 1]);
276273
this._consoleOpened = true;
274+
await consolePanel.console.inject(
275+
`from jupytercad import CadDocument\ndoc = CadDocument("${jcadPath}")`
276+
);
277277
consolePanel.console.sessionContext.kernelChanged.connect((_, arg) => {
278278
if (!arg.newValue) {
279279
this.removeConsole();

packages/schema/src/model.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export class JupyterCadModel implements IJupyterCadModel {
3535
this._pathChanged = new Signal<JupyterCadModel, string>(this);
3636
}
3737

38-
readonly collaborative =
39-
document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined;
38+
readonly collaborative = true;
4039

4140
get sharedModel(): IJupyterCadDoc {
4241
return this._sharedModel;

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ python_packages = [
2323
"python/jupytercad_app:jupytercad_app",
2424
"python/jupytercad_core:jupytercad_core",
2525
"python/jupytercad_lab:jupytercad_lab",
26+
"python/jupytercad_lite:jupytercad",
2627
]
2728

2829
[tool.jupyter-releaser.hooks]

python/jupytercad/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ dependencies = [
2222
"jupytercad_core==3.0.1",
2323
"jupytercad_lab==3.0.1",
2424
"jupytercad_app==3.0.1",
25+
"jupyter-collaboration>=3,<4",
26+
"jupyterlab>=4.3,<5",
2527
]
2628
dynamic = ["version"]
2729
license = {file = "LICENSE"}

python/jupytercad_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"@lumino/widgets": "^2.0.0",
109109
"react": "^18.0.1",
110110
"yjs": "^13.5.40",
111-
"yjs-widgets": "^0.3.7"
111+
"yjs-widgets": "^0.4"
112112
},
113113
"devDependencies": {
114114
"@jupyterlab/builder": "^4.0.0",

python/jupytercad_core/jupytercad_core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
warnings.warn("Importing 'jupytercad_core' outside a proper installation.")
1010
__version__ = "dev"
1111

12-
from .handlers import setup_handlers
13-
1412

1513
def _jupyter_labextension_paths():
1614
return [{"src": "labextension", "dest": "@jupytercad/jupytercad-core"}]
@@ -24,5 +22,7 @@ def _load_jupyter_server_extension(server_app):
2422
server_app: jupyterlab.labapp.LabApp
2523
JupyterLab application instance
2624
"""
25+
from .handlers import setup_handlers
26+
2727
setup_handlers(server_app.web_app)
2828
server_app.log.info("Registered jupytercad server extension")

0 commit comments

Comments
 (0)