Skip to content

Commit

Permalink
update conditions for js build
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
minrk committed Mar 25, 2022
1 parent c6107f7 commit 227901c
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import glob
import os
import sys

Expand Down Expand Up @@ -61,14 +62,35 @@ def run(self):
sys.path.insert(0, '')
from setupbase import wrap_installers, npm_builder, get_data_files

data_files = get_data_files(data_files_spec)

builder = npm_builder(build_cmd="build:prod", npm="jlpm")

cmdclass = {}
if os.environ.get("IPP_DISABLE_JS") == "1":
print("Skipping js installation")
cmdclass = {}
else:
cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder)
# this tells us if labextension is built at all, not if it's up-to-date
labextension_built = glob.glob(os.path.join(lab_path, "*"))
if not labextension_built:
# jupyter-packaging doesn't update data_files or package_data correctly
# after running builds
# run build first if we know it's needed
builder()
# don't need to run it again
needs_js = False

needs_js = True
if not os.path.isdir(os.path.join(here, ".git")):
print("Installing from a dist, not a repo")
# not in a repo, probably installing from sdist
# could be git-archive, though!
# skip rebuilding js if it's already present
if labextension_built:
print(f"Not regenerating labextension in {lab_path}")
needs_js = False

if needs_js:
cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder)


if "bdist_egg" not in sys.argv:
cmdclass["bdist_egg"] = bdist_egg_disabled
Expand All @@ -78,7 +100,7 @@ def run(self):
version=version_ns["__version__"],
packages=setuptools.find_packages(),
description="Interactive Parallel Computing with IPython",
data_files=data_files,
data_files=get_data_files(),
long_description=readme,
long_description_content_type="text/markdown",
author="IPython Development Team",
Expand Down

0 comments on commit 227901c

Please sign in to comment.