Skip to content

Commit 1411cd6

Browse files
authored
Merge pull request #81 from jtpio/skip-if-exists
Skip building js assets if they already exist
2 parents d073ffe + d34b28c commit 1411cd6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.7.0", "jupyterlab>=3.0.0rc10,==3.*", "setuptools>=40.8.0", "wheel"]
2+
requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc10,==3.*", "setuptools>=40.8.0", "wheel"]
33
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import os
2-
from glob import glob
32

43
import setuptools
54
from jupyter_packaging import combine_commands
65
from jupyter_packaging import create_cmdclass
76
from jupyter_packaging import ensure_targets
8-
from jupyter_packaging import get_version
97
from jupyter_packaging import install_npm
8+
from jupyter_packaging import skip_if_exists
109

1110
# The directory containing this file
1211
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -20,10 +19,7 @@
2019
nb_path = os.path.join(HERE, PACKAGE_NAME, "static")
2120

2221
# Representative files that should exist after a successful build
23-
jstargets = [
24-
os.path.join(src_path, "lib", "index.js"),
25-
os.path.join(lab_path, "package.json"),
26-
]
22+
jstargets = [os.path.join(lab_path, "package.json")]
2723

2824
package_data_spec = {PACKAGE_NAME: ["*"]}
2925

@@ -55,11 +51,17 @@
5551
"jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec
5652
)
5753

58-
cmdclass["jsdeps"] = combine_commands(
54+
js_command = combine_commands(
5955
install_npm(src_path, build_cmd="build:prod", npm=["jlpm"]),
6056
ensure_targets(jstargets),
6157
)
6258

59+
is_repo = os.path.exists(os.path.join(HERE, ".git"))
60+
if is_repo:
61+
cmdclass["jsdeps"] = js_command
62+
else:
63+
cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command)
64+
6365
with open("README.md", "r") as fh:
6466
long_description = fh.read()
6567

0 commit comments

Comments
 (0)