Skip to content

Commit 614e478

Browse files
authored
Use hatch backend (jupyter#6425)
1 parent 3760a38 commit 614e478

15 files changed

+155
-210
lines changed

.bumpversion.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ current_version = 7, 0, 0, "alpha", 4
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \"(?P<release>\S+)\"\,\ (?P<build>\d+)
6-
serialize =
6+
serialize =
77
{major}, {minor}, {patch}, "{release}", {build}
88

99
[bumpversion:part:release]
1010
optional_value = final
11-
values =
11+
values =
1212
alpha
1313
beta
1414
candidate

.flake8

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[flake8]
2+
ignore = E501, W503, E402
3+
builtins = c, get_config
4+
exclude =
5+
.cache,
6+
.github,
7+
docs,
8+
enable-extensions = G
9+
extend-ignore =
10+
G001, G002, G004, G200, G201, G202,
11+
# black adds spaces around ':'
12+
E203,

.github/workflows/build.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232

3333
test:
3434
runs-on: ubuntu-latest
35+
timeout-minutes: 10
3536
steps:
3637
- name: Checkout
3738
uses: actions/checkout@v2
@@ -43,7 +44,7 @@ jobs:
4344

4445
- name: Install the package
4546
run: |
46-
python -m pip install ".[test]"
47+
python -m pip install ".[dev,test]"
4748
jlpm run build:test
4849
4950
- name: Unit tests
@@ -60,6 +61,7 @@ jobs:
6061
install:
6162
needs: [build]
6263
runs-on: ${{ matrix.os }}
64+
timeout-minutes: 10
6365
strategy:
6466
fail-fast: false
6567
matrix:

.github/workflows/buildutils.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ concurrency:
1616
jobs:
1717
versioning:
1818
runs-on: ubuntu-latest
19+
timeout-minutes: 10
1920
steps:
2021
- name: Checkout
2122
uses: actions/checkout@v2
@@ -25,7 +26,7 @@ jobs:
2526

2627
- name: Install dependencies
2728
run: |
28-
python -m pip install -U "jupyterlab>=4.0.0a25,<5" jupyter_packaging~=0.10
29+
python -m pip install -U "jupyterlab>=4.0.0a25,<5" hatch
2930
jlpm
3031
jlpm run build
3132
@@ -80,6 +81,6 @@ jobs:
8081

8182
- name: Install dependencies
8283
run: |
83-
python -m pip install -U "jupyterlab>=4.0.0a25,<5" jupyter_packaging~=0.10 pip
84+
python -m pip install -U "jupyterlab>=4.0.0a25,<5" pip
8485
jlpm
8586
jlpm run build

.github/workflows/check-release.yml

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ concurrency:
1515
jobs:
1616
check_release:
1717
runs-on: ubuntu-latest
18+
timeout-minutes: 30
1819
strategy:
1920
matrix:
2021
group: [check_release, link_check]
@@ -36,3 +37,10 @@ jobs:
3637
- name: Check Links
3738
if: ${{ matrix.group == 'link_check' }}
3839
uses: jupyter-server/jupyter_releaser/.github/actions/check-links@v1
40+
41+
- name: Upload Distributions
42+
uses: actions/upload-artifact@v2
43+
if: ${{ matrix.group == 'check_release' }}
44+
with:
45+
name: notebook-jupyter-releaser-dist-${{ github.run_number }}
46+
path: .jupyter_releaser_checkout/dist

.github/workflows/docs.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ concurrency:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14+
timeout-minutes: 10
1415
steps:
1516
- name: Checkout
1617
uses: actions/checkout@v2
@@ -20,7 +21,7 @@ jobs:
2021
python_version: '3.7'
2122
- name: Install the Python dependencies
2223
run: |
23-
pip install -e .[test] codecov
24+
pip install -e .[dev,test] codecov
2425
pip install -r docs/doc-requirements.txt
2526
wget https://github.com/jgm/pandoc/releases/download/1.19.1/pandoc-1.19.1-1-amd64.deb && sudo dpkg -i pandoc-1.19.1-1-amd64.deb
2627
- name: List installed packages

.github/workflows/ui-tests.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
ui-tests:
2525
needs: [build]
2626
runs-on: ubuntu-latest
27+
timeout-minutes: 10
2728
strategy:
2829
fail-fast: false
2930
matrix:
@@ -32,21 +33,14 @@ jobs:
3233
- name: Checkout
3334
uses: actions/checkout@v2
3435

35-
- name: Install Python
36-
uses: actions/setup-python@v2
37-
with:
38-
python-version: '3.9'
39-
architecture: 'x64'
36+
- name: Base Setup
37+
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
4038

4139
- uses: actions/download-artifact@v2
4240
with:
4341
name: notebook-dist-${{ github.run_number }}
4442
path: ./dist
4543

46-
- name: Install the prerequisites
47-
run: |
48-
python -m pip install pip wheel
49-
5044
- name: Install the package
5145
run: |
5246
cd dist

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mamba create -n notebook -c conda-forge python nodejs -y
2222
mamba activate notebook
2323

2424
# Install package in development mode
25-
pip install -e .
25+
pip install -e ".[dev,test]"
2626

2727
# Link the notebook extension and @jupyter-notebook schemas
2828
jlpm develop
@@ -107,7 +107,7 @@ speeding up the review process.
107107
As long as your code is valid,
108108
the pre-commit hook should take care of how it should look.
109109
`pre-commit` and its associated hooks will automatically be installed when
110-
you run `pip install -e ".[test]"`
110+
you run `pip install -e ".[dev,test]"`
111111

112112
To install `pre-commit` manually, run the following:
113113

MANIFEST.in

-28
This file was deleted.

buildutils/src/develop.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ commander
4343
);
4444
if (overwrite) {
4545
try {
46-
fs.unlinkSync(destDir);
47-
console.log('Removed previous symlink:', destDir);
46+
fs.removeSync(destDir);
47+
console.log('Removed previous destination:', destDir);
4848
} catch (e) {
49-
console.info('Skip unlinkink', destDir);
49+
console.info('Skip unlink', destDir);
5050
}
5151
}
5252
console.log('Symlinking:', sourceDir, destDir);

buildutils/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { run } from '@jupyterlab/buildutils';
44
* Get the current version of notebook
55
*/
66
export function getPythonVersion(): string {
7-
const cmd = 'python setup.py --version';
7+
const cmd = 'hatchling version';
88
const lines = run(cmd, { stdio: 'pipe' }, true).split('\n');
99
return lines[lines.length - 1];
1010
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
]
8282
},
8383
"skip": [
84-
"check-links"
84+
"check-links",
85+
"check-manifest"
8586
]
8687
}
8788
}

pyproject.toml

+111-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,126 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.10", "jupyterlab>=4.0.0a25,<5", "pre-commit"]
3-
build-backend = "jupyter_packaging.build_api"
2+
requires = ["hatchling>=1.0", "jupyterlab>=4.0.0a25,<5"]
3+
build-backend = "hatchling.build"
44

5-
[license]
6-
file="LICENSE"
5+
[project]
6+
name = "notebook"
7+
description = "Jupyter Notebook - A web-based notebook environment for interactive computing"
8+
readme = "README.md"
9+
license = { file = "LICENSE" }
10+
requires-python = ">=3.7"
11+
authors = [
12+
{ name = "Jupyter Development Team", email = "[email protected]" },
13+
]
14+
keywords = [
15+
"Jupyter",
16+
"JupyterLab",
17+
"Notebook",
18+
]
19+
classifiers = [
20+
"Framework :: Jupyter",
21+
"Intended Audience :: Developers",
22+
"Intended Audience :: Science/Research",
23+
"Intended Audience :: System Administrators",
24+
"License :: OSI Approved :: BSD License",
25+
"Programming Language :: Python",
26+
"Programming Language :: Python :: 3.7",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
]
31+
dependencies = [
32+
"jupyter_server>=1.16.0,<2",
33+
"jupyterlab>=4.0.0a24,<5",
34+
"jupyterlab_server>=2.13,<3",
35+
"notebook_shim>=0.1,<0.2",
36+
"tornado>=6.1.0",
37+
]
38+
dynamic = ["version"]
739

8-
[tool.jupyter-packaging.options]
9-
skip-if-exists = ["notebook/labextension/static/style.js", "notebook/static/bundle.js"]
10-
ensured-targets = ["notebook/labextension/static/style.js", "notebook/static/bundle.js"]
40+
[project.scripts]
41+
jupyter-notebook = "notebook.app:main"
1142

12-
[tool.jupyter-packaging.builder]
13-
factory = "jupyter_packaging.npm_builder"
43+
[project.urls]
44+
Documentation = "https://jupyter-notebook.readthedocs.io/"
45+
Homepage = "https://github.com/jupyter/notebook"
46+
Source = "https://github.com/jupyter/notebook"
47+
Tracker = "https://github.com/jupyter/notebook/issues"
1448

15-
[tool.jupyter-packaging.build-args]
16-
build_cmd = "build:prod"
17-
npm = ["jlpm"]
49+
[project.optional-dependencies]
50+
test = [
51+
"coverage",
52+
"nbval",
53+
"pytest>=6.0",
54+
"pytest-cov",
55+
"requests",
56+
"pytest-tornasync",
57+
"pytest-timeout",
58+
"pytest-console-scripts",
59+
"ipykernel",
60+
"jupyterlab_server[test]>=2.13,<3",
61+
]
62+
dev = [
63+
"pre-commit",
64+
"bump2version",
65+
"hatchling"
66+
]
67+
68+
[tool.hatch.version]
69+
path = "notebook/_version.py"
70+
source = "code"
71+
72+
[tool.hatch.build.targets.wheel.shared-data]
73+
"notebook/labextension" = "share/jupyter/labextensions/@jupyter-notebook/lab-extension"
74+
"notebook/schemas/@jupyter-notebook" = "share/jupyter/lab/schemas/@jupyter-notebook"
75+
"jupyter-config/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"
1876

19-
[tool.check-manifest]
20-
ignore = ["app/**", "binder/**", "buildutils/**", "docs/**", "packages/**", "codecov.yml", "*.json", "yarn.lock", "readthedocs.yml", ".bumpversion.cfg", ".*", "lint-staged.config.js", "*.svg", "notebook/labextension/**", "notebook/schemas/**", "notebook/static/**", "notebook/template/**", "ui-tests/**"]
77+
[tool.hatch.build.targets.sdist]
78+
artifacts = [
79+
"notebook/labextension",
80+
"notebook/static",
81+
"notebook/schemas/@jupyter-notebook",
82+
"notebook/templates",
83+
]
84+
include = [
85+
"/jupyter-config",
86+
"/notebook",
87+
"/tests",
88+
"/package.json",
89+
"/install.json",
90+
"/ts*.json",
91+
"/*.md"
92+
]
93+
94+
[tool.hatch.build.targets.wheel]
95+
artifacts = [
96+
"notebook/static",
97+
"notebook/templates",
98+
]
99+
include = ["/notebook"]
100+
101+
102+
[tool.hatch.build.hooks.jupyter-builder]
103+
dependencies = ["hatch-jupyter-builder>=0.2"]
104+
build-function = "hatch_jupyter_builder.npm_builder"
105+
ensured-targets = [
106+
"notebook/labextension/static/style.js",
107+
"notebook/static/bundle.js"
108+
]
109+
install-pre-commit-hook = true
110+
111+
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
112+
build_cmd = "build:prod"
113+
editable_build_cmd = "build"
114+
source_dir = "packages"
115+
build_dir = "notebook/static"
116+
npm = "jlpm"
21117

22118
[tool.pytest.ini_options]
23119
addopts = "-raXs --durations 10 --color=yes --doctest-modules"
24120
testpaths = [
25-
"tests/"
121+
"tests/",
26122
]
27123
timeout = 300
28-
# Restore this setting to debug failures
29-
# timeout_method = "thread"
30124
filterwarnings = [
31125
"error",
32126
"ignore:There is no current event loop:DeprecationWarning",

0 commit comments

Comments
 (0)