Skip to content

Commit

Permalink
fixed layout of labextension in dist; `jupyter labextension develop…
Browse files Browse the repository at this point in the history
…` now works
  • Loading branch information
telamonian committed Jun 3, 2021
1 parent 04cc321 commit 253efa1
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ ENV/

.DS_Store

*/labextension
.autoversion
.jupyter
docs/api
docs/index.md
js/labextension
python_junit.xml

3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ include jupyterfs/browser-test.js
include pyproject.toml
include setup.cfg

graft labextension

# javascript pkg files
include js/package.json
include js/ts*.json

graft js/labextension
graft js/src
graft js/style
prune js/build
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ clean: ## clean the repository
rm -rf binder/.[!.]* binder/*.ipynb
## build state
cd js; ${YARN} clean:slate
rm -rf *.egg-info *junit.xml .*-log.txt .jupyter/ .local/ .pytest_cache/ build/ coverage* dist/ MANIFEST node_modules/ pip-wheel-metadata
rm -rf *.egg-info *junit.xml .*-log.txt .jupyter/ .local/ .pytest_cache/ build/ coverage* dist/ MANIFEST node_modules/ pip-wheel-metadata jupyterfs/labextension
# make -C ./docs clean
## package lock files
# rm -rf package-lock.json yarn-lock.json js/package-lock.json js/yarn-lock.json
Expand Down
3 changes: 1 addition & 2 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"clean:slate": "jlpm clean && jlpm clean:labextension && rimraf node_modules",
"deduplicate": "jlpm yarn-deduplicate -s fewer ../yarn.lock || jlpm yarn-deduplicate -s fewer",
"fix": "jlpm lint --fix",
"install:extension": "jupyter labextension develop --overwrite .",
"integrity": "jlpm install && jlpm deduplicate && jlpm install",
"lint": "eslint -c .eslintrc.js --ext .js,.ts,.tsx src/ tests/",
"postpack": "shx rm README.md",
Expand Down Expand Up @@ -107,7 +106,7 @@
}
},
"extension": true,
"outputDir": "labextension",
"outputDir": "../jupyterfs/labextension",
"schemaDir": "schema"
}
}
13 changes: 13 additions & 0 deletions jupyterfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@
# the Apache License 2.0. The full license can be found in the LICENSE file.
#
from ._version import __version__ # noqa: F401

import json
from pathlib import Path

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"],
}]
16 changes: 8 additions & 8 deletions jupyterfs/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@


def _jupyter_server_extension_paths():
return [{'module': 'jupyterfs.extension'}]
return [{"module": "jupyterfs.extension"}]


def load_jupyter_server_extension(nb_server_app):
def load_jupyter_server_extension(serverapp):
"""
Called when the extension is loaded.
Args:
nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
"""
web_app = nb_server_app.web_app
base_url = web_app.settings['base_url']
host_pattern = '.*$'
web_app = serverapp.web_app
base_url = web_app.settings["base_url"]
host_pattern = ".*$"

if not isinstance(nb_server_app.contents_manager, MetaManager):
if not isinstance(serverapp.contents_manager, MetaManager):
warnings.warn(_mm_config_warning_msg)
return

resources_url = 'jupyterfs/resources'
print('Installing jupyter-fs resources handler on path %s' % url_path_join(base_url, resources_url))
resources_url = "jupyterfs/resources"
print("Installing jupyter-fs resources handler on path %s" % url_path_join(base_url, resources_url))
web_app.add_handlers(host_pattern, [(url_path_join(base_url, resources_url), MetaManagerHandler)])
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"license": "BSD-3-Clause",
"workspaces": ["js"],
"scripts": {
"develop": "jupyter labextension develop --overwrite .",
"test:browser": "yarn --cwd ./js test:browser"
}
}
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
# relative paths to python pkg dir and labextension pkg dir
js_pkg, py_pkg = Path('js'), Path('jupyterfs')
# relative path to labextension dist that gets built at the root of the python package
labext_dist = js_pkg/'labextension'
labext_dist = py_pkg/'labextension'
# Representative files that should exist after a successful build
jstargets = [labext_dist/"package.json"]
version = get_version(str(py_pkg / '_version.py'))
# POSIX_PREFIX/APP_SUFFIX determines the install location of the labextension dist
# POSIX_PREFIX/(APP_SUFFIX, CONFIG_SUFFIX) determines the install location of the (labextension dist, extension config)
APP_SUFFIX = Path('share/jupyter/labextensions/')
# POSIX_PREFIX/CONFIG_SUFFIX determines the install location of the extension config
CONFIG_SUFFIX = Path('etc/jupyter/')

with open('README.md', encoding='utf-8') as f:
Expand Down

0 comments on commit 253efa1

Please sign in to comment.