Skip to content

Commit 05f285a

Browse files
Upgrade extension to support jupyterlab v4 (#60)
* Upgrade extension to support jupyterlab v4 * Add fallback for os module * Extend jupyterlab's webpack config to set fallback for os module * Remove node install script * Add release script * Update ipywidget requires
1 parent b5a2c83 commit 05f285a

File tree

10 files changed

+5265
-6194
lines changed

10 files changed

+5265
-6194
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,6 @@ dmypy.json
112112

113113
# OSX files
114114
.DS_Store
115+
116+
# Yarn files
117+
.yarn/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enableImmutableInstalls: false
2+
nodeLinker: node-modules

azure-pipelines.yaml

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ stages:
1212
- job: Build
1313
strategy:
1414
matrix:
15-
mac_38:
16-
imageName: 'macOS-12'
15+
linux_py38_jlab3:
16+
imageName: 'ubuntu-22.04'
1717
python.version: '3.8'
18-
mac_37:
19-
imageName: 'macOS-12'
20-
python.version: '3.7'
21-
linux_py38:
22-
imageName: 'ubuntu-20.04'
18+
jupyterlab.version: '3.6.5'
19+
linux_py39_jlab3:
20+
imageName: 'ubuntu-22.04'
21+
python.version: '3.9'
22+
jupyterlab.version: '3.6.5'
23+
linux_py38_jlab4:
24+
imageName: 'ubuntu-22.04'
2325
python.version: '3.8'
24-
linux_py37:
25-
imageName: 'ubuntu-20.04'
26-
python.version: '3.7'
26+
jupyterlab.version: '4.0.3'
27+
linux_py39_jlab4:
28+
imageName: 'ubuntu-22.04'
29+
python.version: '3.9'
30+
jupyterlab.version: '4.0.3'
2731
pool:
2832
vmImage: $(imageName)
2933

@@ -33,42 +37,22 @@ stages:
3337
versionSpec: '$(python.version)'
3438
architecture: 'x64'
3539

36-
- script: |
37-
echo $(node -v)
38-
npm install --global yarn
39-
displayName: 'Install NodeJS and yarn'
40-
condition: eq(variables['imageName'], 'macOS-12')
41-
42-
- script: |
43-
sudo apt-get install curl
44-
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
45-
sudo apt-get install nodejs
46-
displayName: 'Install NodeJS'
47-
condition: eq(variables['imageName'], 'ubuntu-20.04')
48-
49-
- script: |
50-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
51-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
52-
sudo apt update && sudo apt install yarn
53-
displayName: 'Install yarn'
54-
condition: eq(variables['imageName'], 'ubuntu-20.04')
55-
56-
- script: python -m pip install --upgrade ipywidgets traitlets pytest build jupyter-packaging==0.10.6 jupyterlab==3.3.2
40+
- script: python -m pip install --upgrade ipywidgets traitlets pytest build jupyter-packaging==0.10.6 jupyterlab==$(jupyterlab.version)
5741
# pip installs release candidates by default:
5842
# https://github.com/pypa/pip/issues/4969
5943
displayName: 'Install dependencies'
6044

6145
- script: python -m pip install --upgrade black
6246
displayName: 'Install black (linter)'
63-
condition: eq(variables['python.version'], '3.7')
47+
condition: eq(variables['python.version'], '3.8')
6448
- script: black --check .
6549
displayName: 'Test Formating'
66-
condition: eq(variables['python.version'], '3.7')
50+
condition: eq(variables['python.version'], '3.8')
6751

6852
- task: NodeTool@0
6953
inputs:
70-
versionSpec: '14.x'
71-
- script: yarn
54+
versionSpec: '18.x'
55+
- script: jlpm
7256
displayName: 'Install labextension dependencies'
7357
env:
7458
NPM_TOKEN: $(NPM_TOKEN)
@@ -108,23 +92,23 @@ stages:
10892
jobs:
10993
- job: Deploy_package
11094
pool:
111-
vmImage: 'ubuntu-20.04'
95+
vmImage: 'ubuntu-22.04'
11296

11397
steps:
11498
- task: UsePythonVersion@0
11599
inputs:
116100
versionSpec: '3.8'
117101
architecture: 'x64'
118102

119-
- script: 'pip install twine build setuptools setuptools_scm jupyter-packaging==0.10.6 jupyterlab==3.3.2'
103+
- script: 'pip install twine build setuptools setuptools_scm jupyter-packaging==0.10.6 jupyterlab==3.6.5'
120104
displayName: 'Install twine/build'
121105

122106
- task: NodeTool@0
123107
inputs:
124-
versionSpec: '14.x'
108+
versionSpec: '18.x'
125109
- script: |
126110
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
127-
yarn
111+
jlpm
128112
displayName: 'Save npm token & install labextension dependencies'
129113
env:
130114
NPM_TOKEN: $(NPM_TOKEN)
@@ -154,18 +138,7 @@ stages:
154138
- script: python -m twine upload -r "pypi-upload" --config-file $(PYPIRC_PATH) dist/*.whl
155139
displayName: 'Release to Pypi'
156140

157-
- script: |
158-
latestGitTag=$(git describe --tags --abbrev=0)
159-
latestGitTag="${latestGitTag:1}"
160-
echo $latestGitTag
161-
if [[ $latestGitTag == *"beta"* ]];
162-
then
163-
echo "Publishing beta version";
164-
yarn publish --new-version $latestGitTag --no-git-tag-version --access public --tag beta
165-
else
166-
echo "Publishing new version";
167-
yarn publish --new-version $(./node_modules/.bin/git-tag-version) --no-git-tag-version --access public
168-
fi
141+
- script: ./scripts/publish.sh
169142
env:
170143
GITHUB_TOKEN: $(GITHUB_TOKEN)
171144
NPM_TOKEN: $(NPM_TOKEN)

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
},
5858
"dependencies": {
5959
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^5 || ^6",
60-
"@jupyterlab/application": "^3.4.5",
60+
"@jupyterlab/application": "^3 || ^4",
6161
"@tiledb-inc/viz-core": "^1.0.2-alpha.2"
6262
},
6363
"devDependencies": {
64-
"@jupyterlab/builder": "^3.1.0",
64+
"@jupyterlab/builder": "^3 || ^4",
6565
"@types/node": "^10.11.6",
6666
"@types/webpack-env": "^1.16.3",
6767
"@typescript-eslint/eslint-plugin": "^4.8.1",
@@ -82,13 +82,14 @@
8282
"style-loader": "^3.2.1",
8383
"svg-url-loader": "^7.1.1",
8484
"ts-loader": "^9.2.5",
85-
"typescript": "~4.1.3",
86-
"webpack": "^5.53.0",
87-
"webpack-cli": "^4.8.0"
85+
"typescript": "~5.1.6",
86+
"webpack": "^5.88.1",
87+
"webpack-cli": "^5.1.4"
8888
},
8989
"jupyterlab": {
9090
"extension": "lib/plugin",
9191
"outputDir": "pybabylonjs/labextension",
92+
"webpackConfig": "./webpack.lab.config.js",
9293
"sharedPackages": {
9394
"@jupyter-widgets/base": {
9495
"bundled": false,

scripts/publish.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
LATEST_GIT_TAG=$(git describe --tags --abbrev=0)
4+
# Remove "v" from the start of the tag e.g. v1.0.0 -> 1.0.0
5+
LATEST_GIT_TAG="${LATEST_GIT_TAG:1}"
6+
# Update package.json's version field
7+
npm version $LATEST_GIT_TAG --no-commit-hooks --no-git-tag-version
8+
9+
echo "Updating package.json with version $LATEST_GIT_TAG"
10+
if [[ $LATEST_GIT_TAG == *"beta"* ]];
11+
then
12+
echo "Publishing beta version $LATEST_GIT_TAG to npm";
13+
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag beta
14+
elif [[ $LATEST_GIT_TAG == *"alpha"* ]];
15+
then
16+
echo "Publishing alpha version $LATEST_GIT_TAG to npm";
17+
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag alpha
18+
else
19+
echo "Publishing new version $LATEST_GIT_TAG to npm";
20+
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public
21+
fi

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
platforms="Linux, Mac OS X, Windows",
7171
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
7272
install_requires=[
73-
"ipywidgets>=7,<9",
73+
"ipywidgets>=7",
7474
],
7575
classifiers=[
7676
"License :: OSI Approved :: MIT License",

webpack.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ const path = require('path');
22

33
// Custom webpack rules
44
const rules = [
5-
{ test: /\.ts$/, loader: 'ts-loader' },
6-
{ test: /\.js$/, loader: 'source-map-loader' },
7-
{ test: /\.css$/, use: ['style-loader', 'css-loader']}
5+
{ test: /\.ts$/, loader: 'ts-loader', type: 'javascript/auto' },
6+
{ test: /\.js$/, loader: 'source-map-loader', type: 'javascript/auto' },
7+
{ test: /\.css$/, use: ['style-loader', 'css-loader'], type: 'javascript/auto'}
88
];
99

1010
// Packages that shouldn't be bundled but loaded at runtime
1111
const externals = ['@jupyter-widgets/base', 'module'];
1212

1313
const resolve = {
1414
// Add '.ts' and '.tsx' as resolvable extensions.
15-
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
15+
extensions: [".webpack.js", ".web.js", ".ts", ".js"],
16+
fallback: {
17+
os: false,
18+
}
1619
};
1720

1821
module.exports = [

webpack.lab.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
resolve: {
3+
fallback: {
4+
os: false
5+
}
6+
}
7+
};

0 commit comments

Comments
 (0)