Skip to content

Commit 2c4e8b2

Browse files
authored
Merge pull request #680 from minrk/setup-fixes
setup.py fixes
2 parents 1dc2b6f + afda01f commit 2c4e8b2

File tree

2 files changed

+318
-182
lines changed

2 files changed

+318
-182
lines changed

setup.py

Lines changed: 27 additions & 5 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

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

64-
data_files = get_data_files(data_files_spec)
65-
6665
builder = npm_builder(build_cmd="build:prod", npm="jlpm")
66+
67+
cmdclass = {}
6768
if os.environ.get("IPP_DISABLE_JS") == "1":
6869
print("Skipping js installation")
69-
cmdclass = {}
7070
else:
71-
cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder)
71+
# this tells us if labextension is built at all, not if it's up-to-date
72+
labextension_built = glob.glob(os.path.join(lab_path, "*"))
73+
if not labextension_built:
74+
# jupyter-packaging doesn't update data_files or package_data correctly
75+
# after running builds
76+
# run build first if we know it's needed
77+
builder()
78+
# don't need to run it again
79+
needs_js = False
80+
81+
needs_js = True
82+
if not os.path.isdir(os.path.join(here, ".git")):
83+
print("Installing from a dist, not a repo")
84+
# not in a repo, probably installing from sdist
85+
# could be git-archive, though!
86+
# skip rebuilding js if it's already present
87+
if labextension_built:
88+
print(f"Not regenerating labextension in {lab_path}")
89+
needs_js = False
90+
91+
if needs_js:
92+
cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder)
93+
7294

7395
if "bdist_egg" not in sys.argv:
7496
cmdclass["bdist_egg"] = bdist_egg_disabled
@@ -78,7 +100,7 @@ def run(self):
78100
version=version_ns["__version__"],
79101
packages=setuptools.find_packages(),
80102
description="Interactive Parallel Computing with IPython",
81-
data_files=data_files,
103+
data_files=get_data_files(data_files_spec),
82104
long_description=readme,
83105
long_description_content_type="text/markdown",
84106
author="IPython Development Team",

0 commit comments

Comments
 (0)