Skip to content

Commit 928cb72

Browse files
authored
Update to Jupyter Packaging 10, adopt the releaser (#38)
* Update to Jupyter Packaging 10, adopt the releaser * Add tornado to build deps * Add jupyterlab dependency * add classifiers * Fix manifest * skip link check for now * Add back Binder * Update manifest ignore list * Rename to binder * fix pip install * Link the lab extensions * pip install . on binder
1 parent 6f64da4 commit 928cb72

11 files changed

+150
-49
lines changed

.github/workflows/build.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
15+
1516
- name: Install node
1617
uses: actions/setup-node@v1
1718
with:
18-
node-version: '12.x'
19+
node-version: '14.x'
20+
1921
- name: Install Python
2022
uses: actions/setup-python@v2
2123
with:
22-
python-version: '3.7'
24+
python-version: '3.9'
2325
architecture: 'x64'
2426

25-
2627
- name: Setup pip cache
2728
uses: actions/cache@v2
2829
with:
@@ -35,6 +36,7 @@ jobs:
3536
- name: Get yarn cache directory path
3637
id: yarn-cache-dir-path
3738
run: echo "::set-output name=dir::$(yarn cache dir)"
39+
3840
- name: Setup yarn cache
3941
uses: actions/cache@v2
4042
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
@@ -45,7 +47,8 @@ jobs:
4547
yarn-
4648
4749
- name: Install dependencies
48-
run: python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9
50+
run: python -m pip install -U jupyterlab~=3.0 jupyter-packaging~=0.10
51+
4952
- name: Build the extension
5053
run: |
5154
jlpm

.github/workflows/check-release.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Check Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
check_release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Install Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: 3.9
24+
architecture: 'x64'
25+
26+
- name: Install node
27+
uses: actions/setup-node@v2
28+
with:
29+
node-version: '14.x'
30+
31+
- name: Get pip cache dir
32+
id: pip-cache
33+
run: |
34+
echo "::set-output name=dir::$(pip cache dir)"
35+
36+
- name: Cache pip
37+
uses: actions/cache@v1
38+
with:
39+
path: ${{ steps.pip-cache.outputs.dir }}
40+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
41+
restore-keys: |
42+
${{ runner.os }}-pip-
43+
44+
- name: Cache checked links
45+
uses: actions/cache@v2
46+
with:
47+
path: ~/.cache/pytest-link-check
48+
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/.md') }}-md-links
49+
restore-keys: |
50+
${{ runner.os }}-linkcheck-
51+
52+
- name: Upgrade packaging dependencies
53+
run: |
54+
pip install --upgrade pip setuptools wheel jupyter-packaging~=0.10 --user
55+
56+
- name: Install Dependencies
57+
run: |
58+
pip install .
59+
60+
- name: Check Release
61+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
62+
with:
63+
token: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Upload Distributions
66+
uses: actions/upload-artifact@v2
67+
with:
68+
name: jupyterlab-snippets-releaser-dist-${{ github.run_number }}
69+
path: .jupyter_releaser_checkout/dist

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
<!-- <START NEW CHANGELOG ENTRY> -->
4+
5+
## 0.4.0
6+
7+
### Changes
8+
9+
- Don't list hidden folder #25
10+
- Correct hidden folder removal #26
11+
- Port to JupyterLab 3 #33
12+
13+
Many thanks @fcollonval for the contributions!
14+
15+
<!-- <END NEW CHANGELOG ENTRY> -->

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include LICENSE
2-
include README.md
2+
include *.md
33
include pyproject.toml
44
include jupyter-config/jupyterlab-snippets.json
55

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Github Actions Status](https://github.com/QuantStack/jupyterlab-snippets/workflows/Build/badge.svg)
44
[![Version](https://img.shields.io/pypi/v/jupyterlab-snippets.svg)](https://pypi.python.org/project/jupyterlab-snippets)
55
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/jupyterlab-snippets.svg)](https://anaconda.org/conda-forge/jupyterlab-snippets)
6-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantStack/jupyterlab-snippets/stable?urlpath=lab/tree/binder/notebook.ipynb)
6+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantStack/jupyterlab-snippets/stable?urlpath=lab/tree/binder/example.ipynb)
77

88
Snippets Extension for JupyterLab.
99

binder/environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ dependencies:
1616
# labextension build dependencies
1717
- nodejs >=14,<15
1818
- pip
19-
- wheel
19+
- wheel
File renamed without changes.

binder/postBuild

100755100644
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env sh
22
""" perform a development install of jupyterlab-snippets
3-
43
On Binder, this will run _after_ the environment has been fully created from
54
the environment.yml in this directory.
65
"""
@@ -32,7 +31,7 @@ cd ..
3231
python -m pip check
3332

3433
# install the labextension
35-
python -m pip install -e .
34+
python -m pip install .
3635

3736
# verify the environment the extension didn't break anything
3837
python -m pip check
@@ -45,4 +44,4 @@ jupyter labextension list
4544

4645

4746
echo "JupyterLab with jupyterlab-snippets is ready to run with:"
48-
echo " jupyter lab"
47+
echo " jupyter lab"

package.json

+9
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,14 @@
8888
"extension": true,
8989
"outputDir": "jupyterlab_snippets/labextension"
9090
},
91+
"jupyter-releaser": {
92+
"skip": ["check-links"],
93+
"hooks": {
94+
"before-build-npm": [
95+
"python -m pip install jupyterlab~=3.1",
96+
"jlpm"
97+
]
98+
}
99+
},
91100
"styleModule": "style/index.js"
92101
}

pyproject.toml

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["jupyter_packaging~=0.10", "jupyterlab~=3.0", "tornado~=6.1"]
3+
build-backend = "jupyter_packaging.build_api"
4+
5+
[license]
6+
file="LICENSE"
7+
8+
[tool.jupyter-packaging.options]
9+
skip-if-exists = ["jupyterlab_snippets/labextension/static/style.js"]
10+
ensured-targets = ["jupyterlab_snippets/labextension/static/style.js", "jupyterlab_snippets/labextension/package.json"]
11+
12+
[tool.jupyter-packaging.builder]
13+
factory = "jupyter_packaging.npm_builder"
14+
15+
[tool.jupyter-packaging.build-args]
16+
build_cmd = "build:prod"
17+
npm = ["jlpm"]
18+
19+
[tool.check-manifest]
20+
ignore = ["binder/**", "*.json", "*.ipynb", "*.gif", "yarn.lock", ".*", "jupyterlab_snippets/labextension/**", "jupyter-boilerplate-converter/**"]
21+

setup.py

+25-37
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,36 @@
44
import json
55
from pathlib import Path
66

7-
from jupyter_packaging import (
8-
create_cmdclass,
9-
install_npm,
10-
ensure_targets,
11-
combine_commands,
12-
skip_if_exists
13-
)
147
import setuptools
158

169
HERE = Path(__file__).parent.resolve()
1710

1811
# The name of the project
19-
name = "jupyterlab-snippets"
20-
package = name.replace("-", "_")
12+
NAME = "jupyterlab-snippets"
13+
PY_NAME = NAME.replace('-', '_')
2114

22-
lab_path = (HERE / package / "labextension")
15+
lab_path = (HERE / PY_NAME / "labextension")
2316

2417
# Representative files that should exist after a successful build
25-
jstargets = [
18+
ensured_targets = [
2619
str(lab_path / "package.json"),
20+
str(lab_path / "static/style.js")
2721
]
2822

29-
package_data_spec = {
30-
package: ["*"],
31-
}
32-
33-
labext_name = "jupyterlab-snippets"
34-
3523
data_files_spec = [
36-
("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"),
37-
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
24+
("share/jupyter/labextensions/%s" % NAME, str(lab_path), "**"),
25+
("share/jupyter/labextensions/%s" % NAME, str(HERE), "install.json"),
3826
("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jupyterlab_snippets.json"),
3927
("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jupyterlab_snippets.json"),
4028
]
4129

42-
cmdclass = create_cmdclass("jsdeps",
43-
package_data_spec=package_data_spec,
44-
data_files_spec=data_files_spec
45-
)
46-
47-
js_command = combine_commands(
48-
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
49-
ensure_targets(jstargets),
50-
)
51-
52-
is_repo = (HERE / ".git").exists()
53-
if is_repo:
54-
cmdclass["jsdeps"] = js_command
55-
else:
56-
cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command)
57-
5830
long_description = (HERE / "README.md").read_text()
5931

6032
# Get the package info from package.json
6133
pkg_json = json.loads((HERE / "package.json").read_bytes())
6234

6335
setup_args = dict(
64-
name=name,
36+
name=NAME,
6537
version=pkg_json["version"],
6638
url=pkg_json["homepage"],
6739
author=pkg_json["author"]["name"],
@@ -70,7 +42,6 @@
7042
license=pkg_json["license"],
7143
long_description=long_description,
7244
long_description_content_type="text/markdown",
73-
cmdclass=cmdclass,
7445
packages=setuptools.find_packages(),
7546
install_requires=[
7647
"jupyterlab~=3.0",
@@ -89,9 +60,26 @@
8960
"Programming Language :: Python :: 3.8",
9061
"Programming Language :: Python :: 3.9",
9162
"Framework :: Jupyter",
63+
"Framework :: Jupyter :: JupyterLab",
64+
"Framework :: Jupyter :: JupyterLab :: 3",
65+
"Framework :: Jupyter :: JupyterLab :: Extensions",
66+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
9267
],
9368
)
9469

70+
try:
71+
from jupyter_packaging import (
72+
wrap_installers,
73+
npm_builder,
74+
get_data_files
75+
)
76+
post_develop = npm_builder(
77+
build_cmd="build:prod", source_dir="src", build_dir=lab_path
78+
)
79+
setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
80+
setup_args['data_files'] = get_data_files(data_files_spec)
81+
except ImportError as e:
82+
pass
9583

9684
if __name__ == "__main__":
9785
setuptools.setup(**setup_args)

0 commit comments

Comments
 (0)