Skip to content

Commit 755bc60

Browse files
committed
Update setup.py to handle source installs
Without this Binder errors out because of missing jupyter-packaging, see jupyterlab/extension-cookiecutter-ts#148
1 parent 1a711a5 commit 755bc60

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

setup.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
jupyterlab_execute_time setup.
33
"""
44
import json
5+
import sys
56
from pathlib import Path
67
import setuptools
7-
from jupyter_packaging import wrap_installers, npm_builder, get_data_files
88

99
HERE = Path(__file__).parent.resolve()
1010

@@ -65,13 +65,24 @@
6565
)
6666

6767

68-
post_develop = npm_builder(
69-
build_cmd="install:extension", source_dir="src", build_dir=lab_path, npm="jlpm"
70-
)
71-
setup_args["cmdclass"] = wrap_installers(
72-
post_develop=post_develop, ensured_targets=ensured_targets
73-
)
74-
setup_args["data_files"] = get_data_files(data_files_spec)
68+
try:
69+
from jupyter_packaging import (
70+
wrap_installers,
71+
npm_builder,
72+
get_data_files
73+
)
74+
post_develop = npm_builder(
75+
build_cmd="install:extension", source_dir="src", build_dir=lab_path, npm="jlpm"
76+
)
77+
setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
78+
setup_args["data_files"] = get_data_files(data_files_spec)
79+
except ImportError as e:
80+
import logging
81+
logging.basicConfig(format="%(levelname)s: %(message)s")
82+
logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.")
83+
if not ("--name" in sys.argv or "--version" in sys.argv):
84+
raise e
85+
7586

7687
if __name__ == "__main__":
7788
setuptools.setup(**setup_args)

0 commit comments

Comments
 (0)