Skip to content

Add prebuilt assets when installing from sdist #3231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions packages/python/plotly/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@
# Ensure the folder exists when we will look for files in it
os.makedirs(labstatic)

prebuilt_assets = [
(
"share/jupyter/labextensions/jupyterlab-plotly",
["jupyterlab_plotly/labextension/package.json",],
),
(
"share/jupyter/labextensions/jupyterlab-plotly/static",
[os.path.join(labstatic, f) for f in os.listdir(labstatic)],
),
(
"share/jupyter/nbextensions/jupyterlab-plotly",
[
"jupyterlab_plotly/nbextension/extension.js",
"jupyterlab_plotly/nbextension/index.js",
"jupyterlab_plotly/nbextension/index.js.LICENSE.txt",
],
),
]


if "--skip-npm" in sys.argv or os.environ.get("SKIP_NPM") is not None:
print("Skipping npm install as requested.")
skip_npm = True
Expand Down Expand Up @@ -68,6 +88,7 @@ def run(self):
if not is_repo and all(os.path.exists(t) for t in jsdeps.targets):
# sdist, nothing to do
command.run(self)
self.distribution.data_files.extend(prebuilt_assets)
return

try:
Expand All @@ -94,26 +115,7 @@ def update_package_data(distribution):

# JS assets will not be present if we are skip npm build
if not skip_npm:
distribution.data_files.extend(
[
(
"share/jupyter/labextensions/jupyterlab-plotly",
["jupyterlab_plotly/labextension/package.json",],
),
(
"share/jupyter/labextensions/jupyterlab-plotly/static",
[os.path.join(labstatic, f) for f in os.listdir(labstatic)],
),
(
"share/jupyter/nbextensions/jupyterlab-plotly",
[
"jupyterlab_plotly/nbextension/extension.js",
"jupyterlab_plotly/nbextension/index.js",
"jupyterlab_plotly/nbextension/index.js.LICENSE.txt",
],
),
]
)
distribution.data_files.extend(prebuilt_assets)

# re-init build_py options which load package_data
build_py.finalize_options()
Expand Down