Skip to content

Commit a924e6e

Browse files
author
minjk-bl
committed
Add css-loader and text-loader
1 parent 550bf18 commit a924e6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+420
-341
lines changed

colab/build.colab.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ export VP_NEW_VER=2.2.13
1717
mkdir -p ../dist/colab
1818

1919
# update version info
20-
# rsync -av --exclude='path1/in/source' --exclude='path2/in/source' [source]/ [destination]
21-
rm -rf ../dist/colab/visualpython-v$VP_NEW_VER/*
22-
rsync -avk --exclude='./build.colab.sh' ../colab/ ../dist/colab/visualpython-v$VP_NEW_VER/
23-
grep -REil ${VP_ORG_VER//\./\\.} setup.py visualpython/* | xargs sed -i --follow-symlinks "s/${VP_ORG_VER//\./\\.}/${VP_NEW_VER}/g"
20+
# update manifest version with new numbering for new version
21+
grep -REil ${VP_ORG_VER//\./\\.}\.[0-9] manifest.json | xargs sed -i "s/${VP_ORG_VER//\./\\.}\.[0-9]/${VP_NEW_VER}.1/g"
22+
# update version inside visualpython package
23+
grep -REil ${VP_ORG_VER//\./\\.} visualpython/* | xargs sed -i --follow-symlinks "s/${VP_ORG_VER//\./\\.}/${VP_NEW_VER}/g"
2424

2525
# build package
26+
# sudo apt-get install zip
2627
zip -r ../dist/colab/visualpython-v$VP_NEW_VER.zip background.js content.js icon.png inject.js manifest.json visualpython
2728

2829
exit 0

colab/inject.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ function vp_inject(path) {
2121
s.remove();
2222
}
2323

24+
function vp_css_loader(path) {
25+
return 'css!' + path;
26+
}
27+
28+
function vp_text_loader(path) {
29+
return 'text!' + path + '!strip';
30+
}
31+
32+
function vp_raw_loader(path) {
33+
return 'text!' + path;
34+
}
35+
2436
function vp_config_require() {
2537
// Configure requirejs
2638
try {
@@ -89,9 +101,10 @@ function vp_config_require() {
89101
'css',
90102
'jquery',
91103
'jquery-ui',
92-
'css!vp_base/lib/jquery/jquery-ui.min',
104+
// 'css!vp_base/lib/jquery/jquery-ui.min',
105+
vp_css_loader('vp_base/lib/jquery/jquery-ui.min'),
93106
'codemirror/lib/codemirror',
94-
'css!codemirror/lib/codemirror',
107+
vp_css_loader('codemirror/lib/codemirror'),
95108
'vp_base/js/loadVisualpython'
96109
], function(text, css, $, ui, uiCss, codemirror, cmCss, loadVisualpython) {
97110
// codemirror

jupyterlab/binder/environment.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# a mybinder.org-ready environment for demoing visualpython
2+
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
3+
#
4+
# conda env update --file binder/environment.yml
5+
# conda activate visualpython-demo
6+
#
7+
name: visualpython-demo
8+
9+
channels:
10+
- conda-forge
11+
12+
dependencies:
13+
# runtime dependencies
14+
- python >=3.8,<3.9.0a0
15+
- jupyterlab >=3,<4.0.0a0
16+
# labextension build dependencies
17+
- nodejs >=14,<15
18+
- pip
19+
- wheel
20+
# additional packages for demos
21+
# - ipywidgets

jupyterlab/binder/postBuild

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
""" perform a development install of visualpython
3+
4+
On Binder, this will run _after_ the environment has been fully created from
5+
the environment.yml in this directory.
6+
7+
This script should also run locally on Linux/MacOS/Windows:
8+
9+
python3 binder/postBuild
10+
"""
11+
import subprocess
12+
import sys
13+
from pathlib import Path
14+
15+
16+
ROOT = Path.cwd()
17+
18+
def _(*args, **kwargs):
19+
""" Run a command, echoing the args
20+
21+
fails hard if something goes wrong
22+
"""
23+
print("\n\t", " ".join(args), "\n")
24+
return_code = subprocess.call(args, **kwargs)
25+
if return_code != 0:
26+
print("\nERROR", return_code, " ".join(args))
27+
sys.exit(return_code)
28+
29+
# verify the environment is self-consistent before even starting
30+
_(sys.executable, "-m", "pip", "check")
31+
32+
# install the labextension
33+
_(sys.executable, "-m", "pip", "install", "-e", ".")
34+
35+
# verify the environment the extension didn't break anything
36+
_(sys.executable, "-m", "pip", "check")
37+
38+
# list the extensions
39+
_("jupyter", "server", "extension", "list")
40+
41+
# initially list installed extensions to determine if there are any surprises
42+
_("jupyter", "labextension", "list")
43+
44+
45+
print("JupyterLab with visualpython is ready to run with:\n")
46+
print("\tjupyter lab\n")

jupyterlab/build.jupyterlab.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ grep -REil ${VP_ORG_VER//\./\\.} setup.py visualpython/* | xargs sed -i --follow
2323

2424
mkdir -p ../dist/jupyterlab
2525

26+
# run build as static files
27+
# npm install # install npm package dependencies
28+
# npm run build # optional build step if using TypeScript, babel, etc.
29+
# jupyter labextension install # install the current directory as an extension
30+
jlpm run build
31+
32+
# build file to output dir
2633
python -m build --outdir ../dist/jupyterlab
2734

2835
exit 0

jupyterlab/lib/VpPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define([
88
'jquery-ui',
99
'jquery-ui-css',
1010
'codemirror/lib/codemirror',
11-
// 'codemirror/lib/codemirror.css', // LAB: css! to css-loader
11+
// vp_css_loader('codemirror/lib/codemirror'), // INTEGRATION: unified version of css loader
1212
'vp_base/js/loadVisualpython',
1313
'vp_base/js/com/com_Config'
1414
], function(

jupyterlab/lib/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ const path = require('path');
22
const $ = require('jquery');
33
require("jquery-ui");
44

5-
function vp_text(path) {
5+
function vp_css_loader(path) {
6+
return path + '.css';
7+
}
8+
9+
function vp_text_loader(path) {
610
return '!!text-loader!' + path;
711
}
8-
function vp_css(path) {
12+
13+
function vp_raw_loader(path) {
914
return path;
1015
}
1116

0 commit comments

Comments
 (0)