notebook/setup.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.0 KiB
Python
Raw Normal View History

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
2022-04-01 21:48:40 +08:00
import subprocess
import sys
from pathlib import Path
2020-12-04 21:15:41 +08:00
import setuptools
HERE = Path(__file__).parent.resolve()
2020-12-04 21:15:41 +08:00
# The name of the project
2022-01-18 23:43:12 +08:00
NAME = "notebook"
2020-12-10 05:56:09 +08:00
2022-01-18 20:18:12 +08:00
labext_name = "@jupyter-notebook/lab-extension"
lab_extension_dest = HERE / NAME / "labextension"
main_bundle_dest = HERE / NAME / "static"
2020-12-07 23:37:15 +08:00
# Representative files that should exist after a successful build
ensured_targets = [
str(lab_extension_dest / "static" / "style.js"),
str(main_bundle_dest / "bundle.js"),
2022-01-18 20:18:12 +08:00
str(HERE / NAME / "schemas/@jupyter-notebook/application-extension/package.json.orig"),
2020-12-07 23:37:15 +08:00
]
data_files_spec = [
("share/jupyter/labextensions/%s" % labext_name, str(lab_extension_dest), "**"),
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
2022-01-18 20:18:12 +08:00
("share/jupyter/lab/schemas", f"{NAME}/schemas", "@jupyter-notebook/**/*"),
2020-12-07 23:37:15 +08:00
(
"etc/jupyter/jupyter_server_config.d",
"jupyter-config/jupyter_server_config.d",
2022-01-18 23:43:12 +08:00
"notebook.json",
2020-12-07 23:37:15 +08:00
),
(
"etc/jupyter/jupyter_notebook_config.d",
"jupyter-config/jupyter_notebook_config.d",
2022-01-18 23:43:12 +08:00
"notebook.json",
),
2020-12-07 23:37:15 +08:00
]
try:
from jupyter_packaging import get_data_files, npm_builder, wrap_installers
# In develop mode, just run yarn
2021-10-31 16:25:35 +08:00
builder = npm_builder(build_cmd="build", npm="jlpm", force=True)
2022-04-01 21:48:40 +08:00
def post_develop(*args, **kwargs):
builder(*args, **kwargs)
try:
subprocess.run([sys.executable, "-m", "pre_commit", "install"])
subprocess.run(
[sys.executable, "-m", "pre_commit", "install", "--hook-type", "pre-push"]
)
except Exception:
pass
cmdclass = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
2020-12-04 21:15:41 +08:00
2021-10-31 16:25:35 +08:00
setup_args = dict(cmdclass=cmdclass, data_files=get_data_files(data_files_spec))
except ImportError:
setup_args = {}
2020-12-04 21:15:41 +08:00
if __name__ == "__main__":
setuptools.setup(**setup_args)