diff --git a/.binder/environment.yml b/.binder/environment.yml index 6565cb54..8fb937b4 100644 --- a/.binder/environment.yml +++ b/.binder/environment.yml @@ -22,7 +22,6 @@ channels: dependencies: - python >=3.9 # demo toys - - bqplot - graphviz2drawio - jupyter-lsp-python-lsp-server - jupyterlab-link-share @@ -37,11 +36,16 @@ dependencies: - segno - shapely - tabulate + - sphinx-autobuild + ### FEDERATED EXTENSIONS ### + - bqplot + - jupyterlab_widgets + - jupyterlab-tour - wxyz_datagrid - wxyz_json_schema_form - wxyz_lab - wxyz_svg - - sphinx-autobuild + ### FEDERATED EXTENSIONS ### ############################################################################ ### ipydrawio-docs-deps ### @@ -51,8 +55,6 @@ dependencies: - sphinx - sphinx-jsonschema - sphinxext-rediraffe - # for lite - - jupyterlab-tour # TODO: resolve upstream - sqlalchemy <1.4 - pip: diff --git a/.gitignore b/.gitignore index dba6dc40..e3d296a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ __pycache__ _output +.cache/ .coverage* .eslintcache .ipynb_checkpoints diff --git a/demo/jupyter-lite.json b/demo/jupyter-lite.json index ad3afc05..3a3b8673 100644 --- a/demo/jupyter-lite.json +++ b/demo/jupyter-lite.json @@ -1,14 +1,7 @@ { "jupyter-config-data": { "appName": "IPyDrawioLite", - "disabledExtensions": [ - "@deathbeds/ipydrawio-pdf", - "@jupyterlab-classic/lab-extension", - "@jupyterlab/server-proxy", - "@krassowski/jupyterlab-lsp", - "jupyterlab-server-proxy", - "nbdime-jupyterlab" - ], + "collaborative": true, "faviconUrl": "./favicon.ico" }, "jupyter-lite-schema-version": 0 diff --git a/demo/jupyter_lite_config.json b/demo/jupyter_lite_config.json index 4b63a55d..b747c55d 100644 --- a/demo/jupyter_lite_config.json +++ b/demo/jupyter_lite_config.json @@ -2,9 +2,20 @@ "LiteBuildConfig": { "apps": ["lab"], "contents": ["."], + "federated_extensions": [ + "../py_packages/ipydrawio/dist/ipydrawio-1.1.1-py3-none-any.whl", + "https://github.com/conda-forge/releases/releases/download/noarch/bqplot-0.12.30-pyhd8ed1ab_0.tar.bz2/bqplot-0.12.30-pyhd8ed1ab_0.tar.bz2", + "https://github.com/conda-forge/releases/releases/download/noarch/jupyterlab-tour-3.1.2-pyhd8ed1ab_0.tar.bz2/jupyterlab-tour-3.1.2-pyhd8ed1ab_0.tar.bz2", + "https://github.com/conda-forge/releases/releases/download/noarch/jupyterlab_widgets-1.0.0-pyhd8ed1ab_1.tar.bz2/jupyterlab_widgets-1.0.0-pyhd8ed1ab_1.tar.bz2", + "https://github.com/conda-forge/releases/releases/download/noarch/wxyz_datagrid-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_datagrid-0.5.1-pyhd8ed1ab_0.tar.bz2", + "https://github.com/conda-forge/releases/releases/download/noarch/wxyz_json_schema_form-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_json_schema_form-0.5.1-pyhd8ed1ab_0.tar.bz2", + "https://github.com/conda-forge/releases/releases/download/noarch/wxyz_lab-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_lab-0.5.1-pyhd8ed1ab_0.tar.bz2", + "https://github.com/conda-forge/releases/releases/download/noarch/wxyz_svg-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_svg-0.5.1-pyhd8ed1ab_0.tar.bz2" + ], "ignore_contents": [ "(lab/|_output|.gitignore|doit.db|\\.json$|jupyter_config|log$|\\.cache)" ], + "ignore_sys_prefix": true, "lite_dir": ".", "output_archive": "../build/demo/ipydrawio-lite-1.1.1.tgz", "output_dir": "../build/demo" diff --git a/docs/_templates/demo.html b/docs/_templates/demo.html index 1b5e0f80..a5a9df70 100644 --- a/docs/_templates/demo.html +++ b/docs/_templates/demo.html @@ -6,10 +6,16 @@ data-toggle="tooltip" data-placement="right" title="Try IPyDrawio in your browser. Right now." + id="demo-room-button" > - Try IPyDrawio Now + Try IPyDrawio Now +
+ Collaboration... +
+ everyone who uses this room name will be able to edit all files +

or
Powered by
JupyterLite - + diff --git a/docs/environment.yml b/docs/environment.yml index b667b595..d87dda38 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -29,8 +29,6 @@ dependencies: - sphinx - sphinx-jsonschema - sphinxext-rediraffe - # for lite - - jupyterlab-tour # TODO: resolve upstream - sqlalchemy <1.4 - pip: diff --git a/dodo.py b/dodo.py index f90c7e3d..63867b1e 100644 --- a/dodo.py +++ b/dodo.py @@ -86,6 +86,9 @@ def task_dist(): def task_env(): """sync environments""" + if P.RTD: + return + for env, inherits in P.ENV_INHERITS.items(): yield dict( name=f"""{env.parent.name}:{':'.join([inh.parent.name for inh in inherits])}""", @@ -677,6 +680,24 @@ def task_demo(): print("jupyterlite not found, this might be okay", flush=True) return + yield dict( + name="extensions", + doc="update jupyter-lite.json from the conda env", + file_dep=[P.ENV_BINDER, P.PY_WHEEL[P.IPD.name]], + targets=[P.DEMO_CONFIG], + actions=[ + ( + P._sync_lite_config, + [ + P.ENV_BINDER, + P.DEMO_CONFIG, + P.FED_EXT_MARKER, + [P.PY_WHEEL[P.IPD.name]], + ], + ) + ], + ) + demo_dest = [] demo_tasks = [] final_dest = [] diff --git a/scripts/project.py b/scripts/project.py index 491c156d..d08bb94b 100644 --- a/scripts/project.py +++ b/scripts/project.py @@ -91,6 +91,8 @@ def _clean(*paths_or_globs): TESTING_IN_CI = bool(json.loads(os.environ.get("TESTING_IN_CI", "0"))) CI_ARTIFACT = os.environ.get("CI_ARTIFACT", "wheel") CI = bool(json.loads(os.environ.get("CI", "0"))) +RTD = os.environ.get("READTHEDOCS", "build") + # test arg pass-throughs ATEST_ARGS = json.loads(os.environ.get("ATEST_ARGS", "[]")) @@ -331,6 +333,9 @@ def _norm_js_version(pkg): } # demo +RE_CONDA_FORGE_URL = r"/conda-forge/(.*/)?(noarch|linux-64|win-64|osx-64)/([^/]+)$" +CONDA_FORGE_RELEASE = "https://github.com/conda-forge/releases/releases/download" +FED_EXT_MARKER = "### FEDERATED EXTENSIONS ###" DEMO = ROOT / "demo" DEMO_CONFIG = DEMO / "jupyter_lite_config.json" DEMO_APPS = ["lab"] @@ -806,6 +811,35 @@ def _build_lite(): return False +def _sync_lite_config(from_env, to_json, marker, extras): + """use conda list to derive tarball names""" + raw_lock = subprocess.check_output(["conda", "list", "--explicit"]) + ext_packages = [ + p.strip().split(" ")[0] + for p in from_env.read_text(encoding="utf-8").split(marker)[1].split(" - ") + if p.strip() + ] + + tarball_urls = ["../" + str(extra.relative_to(ROOT).as_posix()) for extra in extras] + for raw_url in sorted(raw_lock.decode("utf-8").splitlines()): + try: + label, subdir, pkg = re.findall(RE_CONDA_FORGE_URL, raw_url)[0] + except IndexError: + continue + + if label: + # TODO: haven't looked into this + continue + + for ext in ext_packages: + if pkg.startswith(ext): + tarball_urls += ["/".join([CONDA_FORGE_RELEASE, subdir, pkg, pkg])] + + config = json.loads(to_json.read_text(encoding="utf-8")) + config["LiteBuildConfig"]["federated_extensions"] = sorted(tarball_urls) + to_json.write_text(json.dumps(config, indent=2, sort_keys=True)) + + # Late environment hacks os.environ.update( CONDARC=str(CONDARC),