diff --git a/.gitignore b/.gitignore index 5241ff5..fb278c7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ node_modules/ *.egg-info/ .ipynb_checkpoints *.tsbuildinfo -jupyterlite_xeus_python/labextension # Created by https://www.gitignore.io/api/python # Edit at https://www.gitignore.io/?templates=python @@ -119,3 +118,6 @@ python_data.data xpython_wasm.js xpython_wasm.wasm xeus_python.worker.js + +# Labextension +share diff --git a/MANIFEST.in b/MANIFEST.in index 5438ca8..da27019 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,7 +9,7 @@ include yarn.lock include webpack.config.js recursive-include tests *.py -graft jupyterlite_xeus_python/labextension +graft share graft docs diff --git a/jupyterlite_xeus_python/__init__.py b/jupyterlite_xeus_python/__init__.py index 360f7cc..93d803f 100644 --- a/jupyterlite_xeus_python/__init__.py +++ b/jupyterlite_xeus_python/__init__.py @@ -1,3 +1,4 @@ +import sys import json from pathlib import Path @@ -5,9 +6,14 @@ 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"]}] + prefix = sys.prefix + # For when in dev mode + if (HERE.parent / 'share' / 'jupyter' / 'labextensions' / '@jupyterlite' / 'xeus-python-kernel').parent.exists(): + prefix = HERE.parent + + return [{ + 'src': prefix / 'share' / 'jupyter' / 'labextensions' / '@jupyterlite' / 'xeus-python-kernel', + 'dest': '@jupyterlite/xeus-python-kernel', + }] diff --git a/jupyterlite_xeus_python/_version.py b/jupyterlite_xeus_python/_version.py index da102d4..0c15733 100644 --- a/jupyterlite_xeus_python/_version.py +++ b/jupyterlite_xeus_python/_version.py @@ -7,19 +7,16 @@ def _fetchVersion(): HERE = Path(__file__).parent.resolve() - for settings in HERE.rglob("package.json"): - try: - with settings.open() as f: - version = json.load(f)["version"] - return ( - version.replace("-alpha.", "a") - .replace("-beta.", "b") - .replace("-rc.", "rc") - ) - except FileNotFoundError: - pass - - raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}") + try: + with open(HERE / "package.json", "r") as f: + version = json.load(f)["version"] + return ( + version.replace("-alpha.", "a") + .replace("-beta.", "b") + .replace("-rc.", "rc") + ) + except FileNotFoundError: + pass __version__ = _fetchVersion() diff --git a/package.json b/package.json index 4f464e3..8b0d5fb 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ }, "jupyterlab": { "extension": true, - "outputDir": "jupyterlite_xeus_python/labextension", + "outputDir": "share/jupyter/labextensions/@jupyterlite/xeus-python-kernel", "webpackConfig": "./webpack.config.js", "sharedPackages": { "@jupyterlite/kernel": { diff --git a/pyproject.toml b/pyproject.toml index 9e0020e..c2bad4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,8 +3,8 @@ requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"] build-backend = "jupyter_packaging.build_api" [tool.jupyter-packaging.options] -skip-if-exists = ["jupyterlite_xeus_python/labextension/static/style.js"] -ensured-targets = ["jupyterlite_xeus_python/labextension/static/style.js", "jupyterlite_xeus_python/labextension/package.json"] +skip-if-exists = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/static/style.js"] +ensured-targets = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/static/style.js", "share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/package.json"] [tool.jupyter-packaging.builder] factory = "jupyter_packaging.npm_builder" @@ -14,4 +14,4 @@ build_cmd = "build:prod" npm = ["jlpm"] [tool.check-manifest] -ignore = ["jupyterlite_xeus_python/labextension/**", "yarn.lock", ".*", "package-lock.json", "Dockerfile", "src/xeus_python.worker.js", "src/xpython_wasm.js", "src/xpython_wasm.wasm", "src/python_data.data", "src/python_data.js", "*.sh"] +ignore = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/**", "yarn.lock", ".*", "package-lock.json", "Dockerfile", "src/xeus_python.worker.js", "src/xpython_wasm.js", "src/xpython_wasm.wasm", "src/python_data.data", "src/python_data.js", "*.sh"] diff --git a/setup.py b/setup.py index 95e87c0..b4ae39f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ # The name of the project name = "jupyterlite-xeus-python" -lab_path = (HERE / name.replace("-", "_") / "labextension") +lab_path = (HERE / "share" / "jupyter" / "labextensions" / "@jupyterlite" / "xeus-python-kernel") # Representative files that should exist after a successful build ensured_targets = [ @@ -20,7 +20,7 @@ str(lab_path / "static/style.js") ] -labext_name = "jupyterlite-xeus-python" +labext_name = "@jupyterlite/xeus-python-kernel" data_files_spec = [ ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"),