Skip to content

Commit 1a19e12

Browse files
committed
Uses hatch
1 parent 1cc904e commit 1a19e12

File tree

8 files changed

+113
-199
lines changed

8 files changed

+113
-199
lines changed

.github/workflows/build.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
1818

1919
- name: Install dependencies
20-
run: python -m pip install -U check-manifest jupyterlab
20+
run: python -m pip install -U jupyterlab~=3.4
2121

2222
- name: Build the extension
2323
run: |
@@ -30,8 +30,6 @@ jobs:
3030
jupyter labextension list 2>&1 | grep -ie "jupyterlab-blockly-extension.*OK"
3131
python -m jupyterlab.browser_check
3232
33-
check-manifest -v
34-
3533
pip install build
3634
python -m build --sdist
3735
cp dist/*.tar.gz myextension.tar.gz

.github/workflows/check-release.yml

+9-45
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,27 @@
11
name: Check Release
22
on:
33
push:
4-
branches:
5-
- main
4+
branches: ["main"]
65
pull_request:
7-
branches:
8-
- main
9-
10-
permissions:
11-
contents: write
6+
branches: ["*"]
127

138
jobs:
149
check_release:
1510
runs-on: ubuntu-latest
1611
steps:
1712
- name: Checkout
18-
uses: actions/checkout@v2
19-
- name: Install Python
20-
uses: actions/setup-python@v2
21-
with:
22-
python-version: 3.9
23-
architecture: 'x64'
24-
- name: Install node
25-
uses: actions/setup-node@v2
26-
with:
27-
node-version: '14.x'
28-
29-
30-
- name: Get pip cache dir
31-
id: pip-cache
32-
run: |
33-
echo "::set-output name=dir::$(pip cache dir)"
34-
- name: Cache pip
35-
uses: actions/cache@v1
36-
with:
37-
path: ${{ steps.pip-cache.outputs.dir }}
38-
key: ${{ runner.os }}-pip-${{ hashFiles('package.json') }}
39-
restore-keys: |
40-
${{ runner.os }}-pip-
41-
- name: Cache checked links
42-
uses: actions/cache@v2
43-
with:
44-
path: ~/.cache/pytest-link-check
45-
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/.md') }}-md-links
46-
restore-keys: |
47-
${{ runner.os }}-linkcheck-
48-
- name: Upgrade packaging dependencies
49-
run: |
50-
pip install --upgrade pip setuptools wheel jupyter-packaging~=0.10 --user
13+
uses: actions/checkout@v3
14+
- name: Base Setup
15+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
5116
- name: Install Dependencies
5217
run: |
53-
pip install .
18+
pip install -e .
5419
- name: Check Release
55-
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
20+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
5621
with:
5722
token: ${{ secrets.GITHUB_TOKEN }}
58-
5923
- name: Upload Distributions
60-
uses: actions/upload-artifact@v2
24+
uses: actions/upload-artifact@v3
6125
with:
62-
name: jupyterlab_blockly-releaser-dist-${{ github.run_number }}
26+
name: jupyterlab_blockly-releaser-dist-${{ '{{ github.run_number }}' }}
6327
path: .jupyter_releaser_checkout/dist

MANIFEST.in

-38
This file was deleted.

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lerna": "5.1.0",
3-
"version": "independent",
3+
"version": "0.2.1",
44
"npmClient": "yarn",
55
"useWorkspaces": true
66
}

package.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
{
22
"name": "jupyterlab-blockly-root",
3-
"version": "0.1.0",
43
"private": true,
4+
"version": "0.2.1",
5+
"description": "Blockly extension for JupyterLab.",
6+
"keywords": [
7+
"jupyter",
8+
"jupyterlab",
9+
"jupyterlab-extension"
10+
],
11+
"homepage": "https://github.com/quantstack/jupyterlab-blockly",
12+
"bugs": {
13+
"url": "https://github.com/quantstack/jupyterlab-blockly/issues"
14+
},
15+
"license": "BSD-3-Clause",
16+
"author": {
17+
"name": "quantstack",
18+
"email": ""
19+
},
520
"workspaces": {
621
"packages": [
722
"packages/*"

pyproject.toml

+67-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,77 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.4"]
3-
build-backend = "jupyter_packaging.build_api"
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling>=1.4.0", "hatch-nodejs-version", "jupyterlab~=3.4"]
44

5-
[tool.jupyter-packaging.options]
6-
skip-if-exists = ["jupyterlab_blockly/labextension/static/style.js"]
7-
ensured-targets = ["jupyterlab_blockly/labextension/static/style.js", "jupyterlab_blockly/labextension/package.json"]
5+
[project]
6+
name = "jupyterlab_blockly"
7+
readme = "README.md"
8+
license = { file = "LICENSE" }
9+
requires-python = ">=3.7"
10+
classifiers = [
11+
"Framework :: Jupyter",
12+
"Framework :: Jupyter :: JupyterLab",
13+
"Framework :: Jupyter :: JupyterLab :: 3",
14+
"Framework :: Jupyter :: JupyterLab :: Extensions",
15+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
16+
"License :: OSI Approved :: BSD License",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.7",
20+
"Programming Language :: Python :: 3.8",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
]
25+
dependencies = [
26+
"jupyterlab~=3.4"
27+
]
28+
dynamic = ["version", "description", "authors", "urls", "keywords"]
29+
30+
[project.optional-dependencies]
31+
dev = [
32+
"click",
33+
"jupyter_releaser==0.22"
34+
]
35+
36+
[tool.hatch.version]
37+
source = "nodejs"
38+
39+
[tool.hatch.metadata.hooks.nodejs]
40+
fields = ["description", "authors", "urls"]
841

9-
[tool.jupyter-packaging.builder]
10-
factory = "jupyter_packaging.npm_builder"
42+
[tool.hatch.build]
43+
artifacts = ["package.json", "scripts", "packages", "patches", "jupyterlab_blockly/labextension"]
44+
exclude = [".github", "binder"]
45+
46+
[tool.hatch.build.targets.wheel.shared-data]
47+
"jupyterlab_blockly/labextension" = "share/jupyter/labextensions/jupyterlab-blockly-extension"
48+
"install.json" = "share/jupyter/labextensions/jupyterlab-blockly-extension/install.json"
49+
50+
[tool.hatch.build.hooks.jupyter-builder]
51+
dependencies = ["hatch-jupyter-builder>=0.5"]
52+
build-function = "hatch_jupyter_builder.npm_builder"
53+
ensured-targets = [
54+
"jupyterlab_blockly/labextension/static/style.js",
55+
"jupyterlab_blockly/labextension/package.json",
56+
]
57+
skip-if-exists = ["jupyterlab_blockly/labextension/static/style.js"]
1158

12-
[tool.jupyter-packaging.build-args]
59+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
1360
build_cmd = "build:prod"
1461
npm = ["jlpm"]
1562

16-
[tool.check-manifest]
17-
ignore = ["jupyterlab_blockly/labextension/**", "packages/**", "assets/**", "lerna.json", "yarn.lock", ".*", "package-lock.json", "docs/**"]
18-
19-
[tool.jupyter-releaser.hooks]
20-
before-bump-version = ["python -m pip install jupyterlab~=3.4"]
21-
before-build-npm = ["python -m pip install jupyterlab", "jlpm"]
63+
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
64+
build_cmd = "install:extension"
65+
npm = ["jlpm"]
66+
build_dir = "jupyterlab_blockly/labextension"
2267

2368
[tool.jupyter-releaser.options]
2469
version-cmd = "python scripts/bump-version.py --force"
70+
71+
[tool.jupyter-releaser.hooks]
72+
before-bump-version = ["python -m pip install jupyterlab~=3.4", "jlpm"]
73+
before-build-npm = ["python -m pip install jupyterlab~=3.4", "jlpm", "jlpm build:prod"]
74+
before-build-python = ["jlpm clean:all"]
75+
76+
[tool.check-wheel-contents]
77+
ignore = ["W002"]

scripts/bump-version.py

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# The full license is in the file LICENSE, distributed with this software. #
88
#############################################################################
99

10+
import json
11+
from pathlib import Path
12+
1013
import click
1114
from jupyter_releaser.util import get_version, run
1215
from pkg_resources import parse_version
@@ -54,6 +57,20 @@ def bump(force, spec):
5457
lerna_cmd += " --yes"
5558
run(lerna_cmd)
5659

60+
HERE = Path(__file__).parent.parent.resolve()
61+
path = HERE.joinpath("package.json")
62+
if path.exists():
63+
with path.open(mode="r") as f:
64+
data = json.load(f)
65+
66+
data["version"] = js_version
67+
68+
with path.open(mode="w") as f:
69+
json.dump(data, f, indent=2)
70+
71+
else:
72+
raise FileNotFoundError(f"Could not find package.json under dir {path!s}")
73+
5774

5875
if __name__ == "__main__":
5976
bump()

setup.py

+2-97
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,2 @@
1-
"""
2-
jupyterlab_blockly setup
3-
"""
4-
import json
5-
import sys
6-
from pathlib import Path
7-
8-
import setuptools
9-
10-
HERE = Path(__file__).parent.resolve()
11-
12-
# The name of the project
13-
name = "jupyterlab_blockly"
14-
15-
lab_path = (HERE / name.replace("-", "_") / "labextension")
16-
17-
# Representative files that should exist after a successful build
18-
ensured_targets = [
19-
str(lab_path / "package.json"),
20-
str(lab_path / "static/style.js")
21-
]
22-
23-
labext_name = "jupyterlab-blockly-extension"
24-
25-
data_files_spec = [
26-
("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"),
27-
("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"),
28-
]
29-
30-
long_description = (HERE / "README.md").read_text()
31-
32-
# Get the package info from package.json
33-
pkg_json = json.loads((HERE / "packages/blockly-extension/package.json").read_bytes())
34-
version = (
35-
pkg_json["version"]
36-
.replace("-alpha.", "a")
37-
.replace("-beta.", "b")
38-
.replace("-rc.", "rc")
39-
)
40-
41-
setup_args = dict(
42-
name=name,
43-
version=version,
44-
url=pkg_json["homepage"],
45-
author=pkg_json["author"]["name"],
46-
author_email=pkg_json["author"]["email"],
47-
description=pkg_json["description"],
48-
license=pkg_json["license"],
49-
license_file="LICENSE",
50-
long_description=long_description,
51-
long_description_content_type="text/markdown",
52-
packages=setuptools.find_packages(),
53-
install_requires=[],
54-
extras_require={
55-
'dev': ['click','jupyter_releaser==0.22']
56-
},
57-
zip_safe=False,
58-
include_package_data=True,
59-
python_requires=">=3.7",
60-
platforms="Linux, Mac OS X, Windows",
61-
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
62-
classifiers=[
63-
"License :: OSI Approved :: BSD License",
64-
"Programming Language :: Python",
65-
"Programming Language :: Python :: 3",
66-
"Programming Language :: Python :: 3.7",
67-
"Programming Language :: Python :: 3.8",
68-
"Programming Language :: Python :: 3.9",
69-
"Programming Language :: Python :: 3.10",
70-
"Framework :: Jupyter",
71-
"Framework :: Jupyter :: JupyterLab",
72-
"Framework :: Jupyter :: JupyterLab :: 3",
73-
"Framework :: Jupyter :: JupyterLab :: Extensions",
74-
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
75-
],
76-
)
77-
78-
try:
79-
from jupyter_packaging import (
80-
wrap_installers,
81-
npm_builder,
82-
get_data_files
83-
)
84-
post_develop = npm_builder(
85-
build_cmd="install:extension", source_dir="src", build_dir=lab_path, npm='jlpm'
86-
)
87-
setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
88-
setup_args["data_files"] = get_data_files(data_files_spec)
89-
except ImportError as e:
90-
import logging
91-
logging.basicConfig(format="%(levelname)s: %(message)s")
92-
logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.")
93-
if not ("--name" in sys.argv or "--version" in sys.argv):
94-
raise e
95-
96-
if __name__ == "__main__":
97-
setuptools.setup(**setup_args)
1+
# setup.py shim for use with applications that require it.
2+
__import__('setuptools').setup()

0 commit comments

Comments
 (0)