Skip to content

Commit

Permalink
Use hatch backend (#6425)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Jun 13, 2022
1 parent 3760a38 commit 614e478
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 210 deletions.
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ current_version = 7, 0, 0, "alpha", 4
commit = False
tag = False
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \"(?P<release>\S+)\"\,\ (?P<build>\d+)
serialize =
serialize =
{major}, {minor}, {patch}, "{release}", {build}

[bumpversion:part:release]
optional_value = final
values =
values =
alpha
beta
candidate
Expand Down
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
ignore = E501, W503, E402
builtins = c, get_config
exclude =
.cache,
.github,
docs,
enable-extensions = G
extend-ignore =
G001, G002, G004, G200, G201, G202,
# black adds spaces around ':'
E203,
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:

test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -43,7 +44,7 @@ jobs:

- name: Install the package
run: |
python -m pip install ".[test]"
python -m pip install ".[dev,test]"
jlpm run build:test
- name: Unit tests
Expand All @@ -60,6 +61,7 @@ jobs:
install:
needs: [build]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/buildutils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ concurrency:
jobs:
versioning:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -25,7 +26,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U "jupyterlab>=4.0.0a25,<5" jupyter_packaging~=0.10
python -m pip install -U "jupyterlab>=4.0.0a25,<5" hatch
jlpm
jlpm run build
Expand Down Expand Up @@ -80,6 +81,6 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U "jupyterlab>=4.0.0a25,<5" jupyter_packaging~=0.10 pip
python -m pip install -U "jupyterlab>=4.0.0a25,<5" pip
jlpm
jlpm run build
8 changes: 8 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrency:
jobs:
check_release:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
group: [check_release, link_check]
Expand All @@ -36,3 +37,10 @@ jobs:
- name: Check Links
if: ${{ matrix.group == 'link_check' }}
uses: jupyter-server/jupyter_releaser/.github/actions/check-links@v1

- name: Upload Distributions
uses: actions/upload-artifact@v2
if: ${{ matrix.group == 'check_release' }}
with:
name: notebook-jupyter-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -20,7 +21,7 @@ jobs:
python_version: '3.7'
- name: Install the Python dependencies
run: |
pip install -e .[test] codecov
pip install -e .[dev,test] codecov
pip install -r docs/doc-requirements.txt
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
- name: List installed packages
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
ui-tests:
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand All @@ -32,21 +33,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

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

- name: Install the prerequisites
run: |
python -m pip install pip wheel
- name: Install the package
run: |
cd dist
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mamba create -n notebook -c conda-forge python nodejs -y
mamba activate notebook

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

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

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

Expand Down
28 changes: 0 additions & 28 deletions MANIFEST.in

This file was deleted.

6 changes: 3 additions & 3 deletions buildutils/src/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ commander
);
if (overwrite) {
try {
fs.unlinkSync(destDir);
console.log('Removed previous symlink:', destDir);
fs.removeSync(destDir);
console.log('Removed previous destination:', destDir);
} catch (e) {
console.info('Skip unlinkink', destDir);
console.info('Skip unlink', destDir);
}
}
console.log('Symlinking:', sourceDir, destDir);
Expand Down
2 changes: 1 addition & 1 deletion buildutils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { run } from '@jupyterlab/buildutils';
* Get the current version of notebook
*/
export function getPythonVersion(): string {
const cmd = 'python setup.py --version';
const cmd = 'hatchling version';
const lines = run(cmd, { stdio: 'pipe' }, true).split('\n');
return lines[lines.length - 1];
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
]
},
"skip": [
"check-links"
"check-links",
"check-manifest"
]
}
}
128 changes: 111 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,126 @@
[build-system]
requires = ["jupyter_packaging~=0.10", "jupyterlab>=4.0.0a25,<5", "pre-commit"]
build-backend = "jupyter_packaging.build_api"
requires = ["hatchling>=1.0", "jupyterlab>=4.0.0a25,<5"]
build-backend = "hatchling.build"

[license]
file="LICENSE"
[project]
name = "notebook"
description = "Jupyter Notebook - A web-based notebook environment for interactive computing"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.7"
authors = [
{ name = "Jupyter Development Team", email = "[email protected]" },
]
keywords = [
"Jupyter",
"JupyterLab",
"Notebook",
]
classifiers = [
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
]
dependencies = [
"jupyter_server>=1.16.0,<2",
"jupyterlab>=4.0.0a24,<5",
"jupyterlab_server>=2.13,<3",
"notebook_shim>=0.1,<0.2",
"tornado>=6.1.0",
]
dynamic = ["version"]

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

[tool.jupyter-packaging.builder]
factory = "jupyter_packaging.npm_builder"
[project.urls]
Documentation = "https://jupyter-notebook.readthedocs.io/"
Homepage = "https://github.com/jupyter/notebook"
Source = "https://github.com/jupyter/notebook"
Tracker = "https://github.com/jupyter/notebook/issues"

[tool.jupyter-packaging.build-args]
build_cmd = "build:prod"
npm = ["jlpm"]
[project.optional-dependencies]
test = [
"coverage",
"nbval",
"pytest>=6.0",
"pytest-cov",
"requests",
"pytest-tornasync",
"pytest-timeout",
"pytest-console-scripts",
"ipykernel",
"jupyterlab_server[test]>=2.13,<3",
]
dev = [
"pre-commit",
"bump2version",
"hatchling"
]

[tool.hatch.version]
path = "notebook/_version.py"
source = "code"

[tool.hatch.build.targets.wheel.shared-data]
"notebook/labextension" = "share/jupyter/labextensions/@jupyter-notebook/lab-extension"
"notebook/schemas/@jupyter-notebook" = "share/jupyter/lab/schemas/@jupyter-notebook"
"jupyter-config/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"

[tool.check-manifest]
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/**"]
[tool.hatch.build.targets.sdist]
artifacts = [
"notebook/labextension",
"notebook/static",
"notebook/schemas/@jupyter-notebook",
"notebook/templates",
]
include = [
"/jupyter-config",
"/notebook",
"/tests",
"/package.json",
"/install.json",
"/ts*.json",
"/*.md"
]

[tool.hatch.build.targets.wheel]
artifacts = [
"notebook/static",
"notebook/templates",
]
include = ["/notebook"]


[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.2"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"notebook/labextension/static/style.js",
"notebook/static/bundle.js"
]
install-pre-commit-hook = true

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
editable_build_cmd = "build"
source_dir = "packages"
build_dir = "notebook/static"
npm = "jlpm"

[tool.pytest.ini_options]
addopts = "-raXs --durations 10 --color=yes --doctest-modules"
testpaths = [
"tests/"
"tests/",
]
timeout = 300
# Restore this setting to debug failures
# timeout_method = "thread"
filterwarnings = [
"error",
"ignore:There is no current event loop:DeprecationWarning",
Expand Down
Loading

0 comments on commit 614e478

Please sign in to comment.