Skip to content

Commit

Permalink
Lab extension files added
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpolak committed Aug 31, 2021
1 parent 95a2f2a commit 709139e
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 96 deletions.
22 changes: 22 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
include README.md
include pyproject.toml
include jupyter-config/k3d.json
recursive-include k3d/static *
include k3d/k3d_extension.json
include setupbase.py

include package.json
include install.json
include ts*.json
include yarn.lock

graft k3d/labextension

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

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
21 changes: 21 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# a mybinder.org-ready environment for demoing k3d
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
#
# conda env update --file binder/environment.yml
# conda activate k3d-demo
#
name: k3d-demo

channels:
- conda-forge

dependencies:
# runtime dependencies
- python >=3.8,<3.9.0a0
- jupyterlab >=3,<4.0.0a0
# labextension build dependencies
- nodejs >=14,<15
- pip
- wheel
# additional packages for demos
# - ipywidgets
46 changes: 46 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
""" perform a development install of k3d
On Binder, this will run _after_ the environment has been fully created from
the environment.yml in this directory.
This script should also run locally on Linux/MacOS/Windows:
python3 binder/postBuild
"""
import subprocess
import sys
from pathlib import Path


ROOT = Path.cwd()

def _(*args, **kwargs):
""" Run a command, echoing the args
fails hard if something goes wrong
"""
print("\n\t", " ".join(args), "\n")
return_code = subprocess.call(args, **kwargs)
if return_code != 0:
print("\nERROR", return_code, " ".join(args))
sys.exit(return_code)

# verify the environment is self-consistent before even starting
_(sys.executable, "-m", "pip", "check")

# install the labextension
_(sys.executable, "-m", "pip", "install", "-e", ".")

# verify the environment the extension didn't break anything
_(sys.executable, "-m", "pip", "check")

# list the extensions
_("jupyter", "server", "extension", "list")

# initially list installed extensions to determine if there are any surprises
_("jupyter", "labextension", "list")


print("JupyterLab with k3d is ready to run with:\n")
print("\tjupyter lab\n")
5 changes: 5 additions & 0 deletions install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "k3d",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package k3d"
}
16 changes: 15 additions & 1 deletion k3d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from ._version import version_info, __version__

import json
from pathlib import Path

from ._version import __version__
from .colormaps import paraview_color_maps
from .colormaps import basic_color_maps
from .colormaps import matplotlib_color_maps
Expand Down Expand Up @@ -33,6 +36,17 @@

from .transform import transform

HERE = Path(__file__).parent.resolve()

with (HERE / "labextension" / "package.json").open() as fid:
data = json.load(fid)

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

def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
Expand Down
21 changes: 19 additions & 2 deletions k3d/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
version_info = (2, 10, 0)
__version__ = '.'.join(map(str, version_info))
import json
from pathlib import Path

__all__ = ["__version__"]

def _fetchVersion():
HERE = Path(__file__).parent.resolve()

for settings in HERE.rglob("package.json"):
try:
with settings.open() as f:
return json.load(f)["version"]
except FileNotFoundError:
pass

raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")

__version__ = _fetchVersion()

12 changes: 12 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = [
{
id: 'k3d',
autoStart: true,
activate: function (app) {
console.log(
'JupyterLab extension k3d is activated!'
);
console.log(app.commands);
}
}
];
57 changes: 57 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "k3d",
"version": "0.1.0",
"description": "3D visualization library",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension"
],
"homepage": "https://github.com/K3D-tools/K3D-jupyter.git",
"bugs": {
"url": "https://github.com/K3D-tools/K3D-jupyter.git/issues"
},
"license": "BSD-3-Clause",
"author": {
"name": "k3d team",
"email": ""
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,.js,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
],
"main": "lib/index.js",
"style": "style/index.css",
"repository": {
"type": "git",
"url": "https://github.com/K3D-tools/K3D-jupyter.git.git"
},
"scripts": {
"build": "jlpm run build:labextension:dev",
"build:prod": "jlpm run build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"clean:labextension": "rimraf k3d/labextension",
"clean:all": "jlpm run clean:labextension",
"install:extension": "jupyter labextension develop --overwrite .",
"prepare": "jlpm run build:prod",
"prettier": "prettier --write \"**/*{.js,.jsx,.css,.json,.md}\"",
"watch": "watch:labextension",
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {},
"devDependencies": {
"@jupyterlab/builder": "^3.0.0",
"prettier": "^2.1.1",
"rimraf": "^3.0.2"
},
"sideEffects": [
"style/*.css",
"style/index.js"
],
"styleModule": "style/index.js",
"jupyterlab": {
"extension": true,
"outputDir": "k3d/labextension"
}
}
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
Loading

0 comments on commit 709139e

Please sign in to comment.