Skip to content

Commit dee3ade

Browse files
committed
update conditions for js build
- if labextension not present, build before computing data_files (fixes incorrect data files when doing `pip install .` from git - if labextension present and not building from a repo, skip rebuild to avoid redundant js rebuilds from an sdist
1 parent c6107f7 commit dee3ade

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

setup.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# Copyright (c) IPython Development Team.
33
# Distributed under the terms of the Modified BSD License.
4+
import glob
45
import os
56
import sys
67

@@ -64,11 +65,35 @@ def run(self):
6465
data_files = get_data_files(data_files_spec)
6566

6667
builder = npm_builder(build_cmd="build:prod", npm="jlpm")
68+
69+
cmdclass = {}
6770
if os.environ.get("IPP_DISABLE_JS") == "1":
6871
print("Skipping js installation")
69-
cmdclass = {}
7072
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+
7297

7398
if "bdist_egg" not in sys.argv:
7499
cmdclass["bdist_egg"] = bdist_egg_disabled

0 commit comments

Comments
 (0)