Skip to content

Commit

Permalink
Update jupyterlab_widgets to Jupyter Packaging 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed May 4, 2021
1 parent e0d41f6 commit fcd824d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
python -m pip install jupyterlab~=3.0
python -m pip install jupyter_packaging
python -m pip install jupyterlab~=3.0 jupyter_packaging~=0.9 check-manifest
- name: Build the extension
run: |
pip install .
Expand All @@ -57,3 +56,5 @@ jobs:
jupyter labextension list
python -m jupyterlab.browser_check
check-manifest -v
4 changes: 2 additions & 2 deletions jupyterlab_widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
"scripts": {
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
"build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc",
Expand All @@ -41,7 +41,7 @@
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"install:extension": "jupyter labextension develop --overwrite .",
"install:extension": "jlpm run build",
"prepare": "jlpm run clean && jlpm run build:prod",
"watch": "run-p watch:src watch:labextension",
"watch:labextension": "jupyter labextension watch .",
Expand Down
14 changes: 12 additions & 2 deletions jupyterlab_widgets/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[build-system]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["jupyter_packaging~=0.9,<1", "jupyterlab~=3.0"]
build-backend = "jupyter_packaging.build_api"

[tool.jupyter-packaging.builder]
factory = "jupyter_packaging.npm_builder"

[tool.jupyter-packaging.build-args]
build_cmd = "build:prod"
npm = ["jlpm"]

[tool.check-manifest]
ignore = ["jupyterlab_widgets/labextension/**", "yarn.lock", ".*", "package-lock.json"]
2 changes: 2 additions & 0 deletions jupyterlab_widgets/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ python_requires = >=3.6
zip_safe=False
include_package_data = True
packages = find:
install_requires =
jupyter_packaging~=0.9,<1
34 changes: 11 additions & 23 deletions jupyterlab_widgets/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
jupyterlab_widgets setup
"""
from jupyter_packaging import (
create_cmdclass, install_npm, ensure_targets,
combine_commands, ensure_python, get_version,
skip_if_exists
wrap_installers,
npm_builder,
get_data_files
)
from pathlib import Path
from setuptools import setup
Expand All @@ -21,33 +21,21 @@
labext_name = "@jupyter-widgets/jupyterlab-manager"

# Representative files that should exist after a successful build
jstargets = [LAB_PATH / "package.json"]

package_data_spec = {name: ["*"]}
ensured_targets = [LAB_PATH / "package.json"]

data_files_spec = [
(f"share/jupyter/labextensions/{labext_name}", LAB_PATH, "**"),
(f"share/jupyter/labextensions/{labext_name}", HERE, "install.json"),
]

cmdclass = create_cmdclass(
"jsdeps",
package_data_spec=package_data_spec,
data_files_spec=data_files_spec
)

# if the static assets already exist, do not invoke npm so we can make a wheel
# from the sdist package, since the npm build really only works from this
# repo.
js_command = combine_commands(
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
ensure_targets(jstargets),
post_develop = npm_builder(
build_cmd="install:extension", source_dir="src", build_dir=LAB_PATH
)

if IS_REPO:
cmdclass["jsdeps"] = js_command
else:
cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command)
cmdclass = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)

if __name__ == "__main__":
setup(cmdclass=cmdclass)
setup(
cmdclass=cmdclass,
data_files=get_data_files(data_files_spec),
)

0 comments on commit fcd824d

Please sign in to comment.