Skip to content

Commit 5415db7

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 5415db7

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

setup.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import json
55
from pathlib import Path
66
import setuptools
7-
from jupyter_packaging import wrap_installers, npm_builder, get_data_files
87

98
HERE = Path(__file__).parent.resolve()
109

@@ -65,13 +64,24 @@
6564
)
6665

6766

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

7686
if __name__ == "__main__":
7787
setuptools.setup(**setup_args)

0 commit comments

Comments
 (0)