Skip to content

Commit

Permalink
Upgrade extension to support jupyterlab v4 (#60)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SarantopoulosKon committed Jul 25, 2023
1 parent b5a2c83 commit 05f285a
Show file tree
Hide file tree
Showing 10 changed files with 5,265 additions and 6,194 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ dmypy.json

# OSX files
.DS_Store

# Yarn files
.yarn/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enableImmutableInstalls: false
nodeLinker: node-modules
75 changes: 24 additions & 51 deletions azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ stages:
- job: Build
strategy:
matrix:
mac_38:
imageName: 'macOS-12'
linux_py38_jlab3:
imageName: 'ubuntu-22.04'
python.version: '3.8'
mac_37:
imageName: 'macOS-12'
python.version: '3.7'
linux_py38:
imageName: 'ubuntu-20.04'
jupyterlab.version: '3.6.5'
linux_py39_jlab3:
imageName: 'ubuntu-22.04'
python.version: '3.9'
jupyterlab.version: '3.6.5'
linux_py38_jlab4:
imageName: 'ubuntu-22.04'
python.version: '3.8'
linux_py37:
imageName: 'ubuntu-20.04'
python.version: '3.7'
jupyterlab.version: '4.0.3'
linux_py39_jlab4:
imageName: 'ubuntu-22.04'
python.version: '3.9'
jupyterlab.version: '4.0.3'
pool:
vmImage: $(imageName)

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

- script: |
echo $(node -v)
npm install --global yarn
displayName: 'Install NodeJS and yarn'
condition: eq(variables['imageName'], 'macOS-12')
- script: |
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install nodejs
displayName: 'Install NodeJS'
condition: eq(variables['imageName'], 'ubuntu-20.04')
- script: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
displayName: 'Install yarn'
condition: eq(variables['imageName'], 'ubuntu-20.04')
- script: python -m pip install --upgrade ipywidgets traitlets pytest build jupyter-packaging==0.10.6 jupyterlab==3.3.2
- script: python -m pip install --upgrade ipywidgets traitlets pytest build jupyter-packaging==0.10.6 jupyterlab==$(jupyterlab.version)
# pip installs release candidates by default:
# https://github.com/pypa/pip/issues/4969
displayName: 'Install dependencies'

- script: python -m pip install --upgrade black
displayName: 'Install black (linter)'
condition: eq(variables['python.version'], '3.7')
condition: eq(variables['python.version'], '3.8')
- script: black --check .
displayName: 'Test Formating'
condition: eq(variables['python.version'], '3.7')
condition: eq(variables['python.version'], '3.8')

- task: NodeTool@0
inputs:
versionSpec: '14.x'
- script: yarn
versionSpec: '18.x'
- script: jlpm
displayName: 'Install labextension dependencies'
env:
NPM_TOKEN: $(NPM_TOKEN)
Expand Down Expand Up @@ -108,23 +92,23 @@ stages:
jobs:
- job: Deploy_package
pool:
vmImage: 'ubuntu-20.04'
vmImage: 'ubuntu-22.04'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
architecture: 'x64'

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

- task: NodeTool@0
inputs:
versionSpec: '14.x'
versionSpec: '18.x'
- script: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
yarn
jlpm
displayName: 'Save npm token & install labextension dependencies'
env:
NPM_TOKEN: $(NPM_TOKEN)
Expand Down Expand Up @@ -154,18 +138,7 @@ stages:
- script: python -m twine upload -r "pypi-upload" --config-file $(PYPIRC_PATH) dist/*.whl
displayName: 'Release to Pypi'

- script: |
latestGitTag=$(git describe --tags --abbrev=0)
latestGitTag="${latestGitTag:1}"
echo $latestGitTag
if [[ $latestGitTag == *"beta"* ]];
then
echo "Publishing beta version";
yarn publish --new-version $latestGitTag --no-git-tag-version --access public --tag beta
else
echo "Publishing new version";
yarn publish --new-version $(./node_modules/.bin/git-tag-version) --no-git-tag-version --access public
fi
- script: ./scripts/publish.sh
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
NPM_TOKEN: $(NPM_TOKEN)
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
},
"dependencies": {
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^5 || ^6",
"@jupyterlab/application": "^3.4.5",
"@jupyterlab/application": "^3 || ^4",
"@tiledb-inc/viz-core": "^1.0.2-alpha.2"
},
"devDependencies": {
"@jupyterlab/builder": "^3.1.0",
"@jupyterlab/builder": "^3 || ^4",
"@types/node": "^10.11.6",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^4.8.1",
Expand All @@ -82,13 +82,14 @@
"style-loader": "^3.2.1",
"svg-url-loader": "^7.1.1",
"ts-loader": "^9.2.5",
"typescript": "~4.1.3",
"webpack": "^5.53.0",
"webpack-cli": "^4.8.0"
"typescript": "~5.1.6",
"webpack": "^5.88.1",
"webpack-cli": "^5.1.4"
},
"jupyterlab": {
"extension": "lib/plugin",
"outputDir": "pybabylonjs/labextension",
"webpackConfig": "./webpack.lab.config.js",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
Expand Down
21 changes: 21 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

LATEST_GIT_TAG=$(git describe --tags --abbrev=0)
# Remove "v" from the start of the tag e.g. v1.0.0 -> 1.0.0
LATEST_GIT_TAG="${LATEST_GIT_TAG:1}"
# Update package.json's version field
npm version $LATEST_GIT_TAG --no-commit-hooks --no-git-tag-version

echo "Updating package.json with version $LATEST_GIT_TAG"
if [[ $LATEST_GIT_TAG == *"beta"* ]];
then
echo "Publishing beta version $LATEST_GIT_TAG to npm";
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag beta
elif [[ $LATEST_GIT_TAG == *"alpha"* ]];
then
echo "Publishing alpha version $LATEST_GIT_TAG to npm";
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public --tag alpha
else
echo "Publishing new version $LATEST_GIT_TAG to npm";
yarn publish --new-version $LATEST_GIT_TAG --no-git-tag-version --no-commit-hooks --access public
fi
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
platforms="Linux, Mac OS X, Windows",
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
install_requires=[
"ipywidgets>=7,<9",
"ipywidgets>=7",
],
classifiers=[
"License :: OSI Approved :: MIT License",
Expand Down
11 changes: 7 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ const path = require('path');

// Custom webpack rules
const rules = [
{ test: /\.ts$/, loader: 'ts-loader' },
{ test: /\.js$/, loader: 'source-map-loader' },
{ test: /\.css$/, use: ['style-loader', 'css-loader']}
{ test: /\.ts$/, loader: 'ts-loader', type: 'javascript/auto' },
{ test: /\.js$/, loader: 'source-map-loader', type: 'javascript/auto' },
{ test: /\.css$/, use: ['style-loader', 'css-loader'], type: 'javascript/auto'}
];

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

const resolve = {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
extensions: [".webpack.js", ".web.js", ".ts", ".js"],
fallback: {
os: false,
}
};

module.exports = [
Expand Down
7 changes: 7 additions & 0 deletions webpack.lab.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
resolve: {
fallback: {
os: false
}
}
};

0 comments on commit 05f285a

Please sign in to comment.