From 47d3ac337c07afab56da1f4f978840b6f3f213f5 Mon Sep 17 00:00:00 2001 From: cjachekang <47467363+cjachekang@users.noreply.github.com> Date: Sun, 18 Apr 2021 18:02:04 -0700 Subject: [PATCH] Catch errors for jupyter-packaging (#83) * try except in setup * added print statement * updated print --- setup.py | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index 0d524ac..4f7fe8e 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,6 @@ import json from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, - install_npm, - ensure_targets, - combine_commands, - skip_if_exists -) import setuptools HERE = Path(__file__).parent.resolve() @@ -35,27 +28,39 @@ labext_name = "luxwidget" -data_files_spec = [ +try: + from jupyter_packaging import ( + create_cmdclass, + install_npm, + ensure_targets, + combine_commands, + skip_if_exists + ) + data_files_spec = [ ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ("share/jupyter/nbextensions/%s" % name, str(nb_path), '**'), -] - -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = (HERE / ".git").exists() -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + ] + + cmdclass = create_cmdclass("jsdeps", + package_data_spec=package_data_spec, + data_files_spec=data_files_spec + ) + + js_command = combine_commands( + install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), + ensure_targets(jstargets), + ) + + is_repo = (HERE / ".git").exists() + if is_repo: + cmdclass["jsdeps"] = js_command + else: + cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) + +except ImportError: + print("jupyter-packaging is not installed. Please install via 'pip install jupyter-packaging'.") + cmdclass = {} long_description = (HERE / "README.md").read_text()