Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Update to JupyterLab 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Nov 11, 2020
1 parent cb30317 commit 595f753
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 26 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build.yml
Expand Up @@ -17,21 +17,22 @@ jobs:
- name: Install node
uses: actions/setup-node@v1
with:
node-version: '10.x'
node-version: '12.x'

- name: Install Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Install JupyterLab
run: python -m pip install jupyterlab nbresuse
run: |
python -m pip install jupyterlab --pre
python -m pip install nbresuse
- name: Build and install the extension
- name: Install the extension
run: |
jlpm
jlpm run build
jlpm run link
python -m pip install .
jupyter labextension list 2>&1 | grep -ie "jupyterlab-system-monitor.*OK"
- name: Browser check
run: python -m jupyterlab.browser_check
Expand Down
103 changes: 103 additions & 0 deletions .gitignore
Expand Up @@ -5,3 +5,106 @@ node_modules/
.ipynb_checkpoints
*.tsbuildinfo
.vscode
jupyterlab-system-monitor/labextension

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# End of https://www.gitignore.io/api/python
23 changes: 23 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,23 @@
include LICENSE
include README.md
include pyproject.toml
include jupyter-config/jupyterlab-system-monitor.json

include package.json
include install.json
include ts*.json

graft jupyterlab-system-monitor/labextension

# Javascript files
graft src
graft style
prune **/node_modules
prune lib

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
29 changes: 24 additions & 5 deletions README.md
Expand Up @@ -25,6 +25,18 @@ This extension was originally developed as part of the [jupyterlab-topbar](https

This extension requires the `nbresuse` package and the `jupyterlab-topbar-extension` extension for JupyterLab.

**Note: This extension is not compatible with `nbresuse==0.3.4`**.

Starting from JupyterLab 3.0, extensions can be distributed as a Python package. Installation instructions will differ depending on your version of JupyterLab:

### JupyterLab 3.x

```bash
pip install jupyterlab-system-monitor
```

### JupyterLab 2.x

```bash
pip install nbresuse
jupyter labextension install jupyterlab-topbar-extension jupyterlab-system-monitor
Expand All @@ -42,8 +54,6 @@ Note: Node.js is required to install JupyterLab extensions. It can be installed
conda install -c conda-forge nodejs
```

Note: This extension is not compatible with `nbresuse==0.3.4`.

## Configuration

### Graphic Display
Expand Down Expand Up @@ -98,9 +108,18 @@ conda activate jupyterlab-system-monitor
# Install dependencies
jlpm

# Build Typescript source
# Install the package in development mode
pip install -e .

# Link your development version of the extension with JupyterLab
jlpm run develop

# Rebuild extension TypeScript source after making changes
jlpm run build
```

### Uninstall

# Link the local extensions
jlpm run link
```bash
pip uninstall jupyterlab-system-monitor
```
5 changes: 5 additions & 0 deletions install.json
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab-system-monitor",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab-system-monitor"
}
19 changes: 19 additions & 0 deletions jupyterlab-system-monitor/__init__.py
@@ -0,0 +1,19 @@

import json
import os.path as osp

from ._version import __version__

HERE = osp.abspath(osp.dirname(__file__))

with open(osp.join(HERE, 'labextension', 'package.json')) as fid:
data = json.load(fid)

def _jupyter_labextension_paths():
return [{
'src': 'labextension',
'dest': data['name']
}]



19 changes: 19 additions & 0 deletions jupyterlab-system-monitor/_version.py
@@ -0,0 +1,19 @@
__all__ = ['__version__']

def _fetchVersion():
import json
import os

HERE = os.path.abspath(os.path.dirname(__file__))

for d, _, _ in os.walk(HERE):
try:
with open(os.path.join(d, 'package.json')) as f:
return json.load(f)['version']
except FileNotFoundError:
pass

raise FileNotFoundError('Could not find package.json under dir {}'.format(HERE))

__version__ = _fetchVersion()

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -4,7 +4,6 @@
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"clean": "lerna run clean",
"link": "lerna run link && jupyter labextension install jupyterlab-topbar-extension",
"lint": "jlpm run eslint && jlpm run prettier",
"lint:check": "jlpm run eslint:check && jlpm run prettier:check",
"eslint": "eslint . --ext .ts,.tsx --fix",
Expand Down
39 changes: 26 additions & 13 deletions packages/system-monitor/package.json
Expand Up @@ -25,22 +25,34 @@
"url": "https://github.com/jtpio/jupyterlab-system-monitor.git"
},
"scripts": {
"build": "tsc",
"link": "jupyter labextension link . --no-build",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"prepare": "npm run clean && npm run build",
"watch": "tsc -w"
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
"clean": "jlpm run clean:lib",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"clean:labextension": "rimraf jupyterlab-system-monitor/labextension",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install:extension": "jupyter labextension develop --overwrite .",
"prepare": "jlpm run clean && jlpm run build:prod",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
"watch:src": "tsc -w"
},
"dependencies": {
"@jupyterlab/application": "^2.0.0",
"@jupyterlab/statusbar": "^2.0.0",
"@jupyterlab/settingregistry": "^2.0.0",
"jupyterlab-topbar": "^0.5.0",
"jupyterlab-system-monitor-base": "^0.6.0"
"@jupyterlab/application": "^3.0.0-rc.7",
"@jupyterlab/settingregistry": "^3.0.0-rc.7",
"@jupyterlab/statusbar": "^3.0.0-rc.7",
"jupyterlab-system-monitor-base": "^0.6.0",
"jupyterlab-topbar": "^0.5.0"
},
"devDependencies": {
"rimraf": "^2.6.1",
"typescript": "~3.8.1"
"@jupyterlab/builder": "^3.0.0-rc.7",
"rimraf": "^3.0.2",
"typescript": "~4.0.3"
},
"jupyterlab": {
"extension": true,
Expand All @@ -55,6 +67,7 @@
"name": "nbresuse"
}
}
}
},
"outputDir": "../../jupyterlab-system-monitor/labextension"
}
}
3 changes: 3 additions & 0 deletions pyproject.toml
@@ -0,0 +1,3 @@
[build-system]
requires = ["jupyter_packaging~=0.7.0", "jupyterlab>=3.0.0rc2,==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"

0 comments on commit 595f753

Please sign in to comment.