|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | # Copyright (c) IPython Development Team.
|
3 | 3 | # Distributed under the terms of the Modified BSD License.
|
| 4 | +import glob |
4 | 5 | import os
|
5 | 6 | import sys
|
6 | 7 |
|
@@ -64,11 +65,35 @@ def run(self):
|
64 | 65 | data_files = get_data_files(data_files_spec)
|
65 | 66 |
|
66 | 67 | builder = npm_builder(build_cmd="build:prod", npm="jlpm")
|
| 68 | + |
| 69 | +cmdclass = {} |
67 | 70 | if os.environ.get("IPP_DISABLE_JS") == "1":
|
68 | 71 | print("Skipping js installation")
|
69 |
| - cmdclass = {} |
70 | 72 | else:
|
71 |
| - cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder) |
| 73 | + # this tells us if labextension is built at all, not if it's up-to-date |
| 74 | + labextension_built = glob.glob(os.path.join(lab_path, "*")) |
| 75 | + if not labextension_built: |
| 76 | + # jupyter-packaging doesn't update data_files or package_data correctly |
| 77 | + # after running builds |
| 78 | + # run build first if we know it's needed |
| 79 | + builder() |
| 80 | + data_files = get_data_files(data_files_spec) |
| 81 | + # don't need to run it again |
| 82 | + needs_js = False |
| 83 | + |
| 84 | + needs_js = True |
| 85 | + if not os.path.isdir(os.path.join(here, ".git")): |
| 86 | + print("Installing from a dist, not a repo") |
| 87 | + # not in a repo, probably installing from sdist |
| 88 | + # could be git-archive, though! |
| 89 | + # skip rebuilding js if it's already present |
| 90 | + if labextension_built: |
| 91 | + print(f"Not regenerating labextension in {lab_path}") |
| 92 | + needs_js = False |
| 93 | + |
| 94 | + if needs_js: |
| 95 | + cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder) |
| 96 | + |
72 | 97 |
|
73 | 98 | if "bdist_egg" not in sys.argv:
|
74 | 99 | cmdclass["bdist_egg"] = bdist_egg_disabled
|
|
0 commit comments