From cded2be744e33be3757a4438c19111d7c4767cb3 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 14 May 2022 15:34:25 -0500 Subject: [PATCH] Use hatch backend add flake8 config add artifacts cleanup use tbump to get current version cleanup for new dep versions clean up workflows switch back to bumpversion fix verion fixup fixup fixup fixup fix version check fixups try version handling again version cleanup fix typescript error undo bump2version changes include schemas and add build timeouts fix workflow syntax more workflow cleanup clean up config --- .bumpversion.cfg | 4 +- .flake8 | 12 +++ .github/workflows/build.yml | 4 +- .github/workflows/buildutils.yml | 5 +- .github/workflows/check-release.yml | 1 + .github/workflows/docs.yml | 3 +- .github/workflows/ui-tests.yml | 12 +-- CONTRIBUTING.md | 4 +- MANIFEST.in | 28 ------- buildutils/src/utils.ts | 2 +- pyproject.toml | 111 +++++++++++++++++++++++----- setup.cfg | 77 ------------------- setup.py | 66 ----------------- 13 files changed, 123 insertions(+), 206 deletions(-) create mode 100644 .flake8 delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 3f95352712..a49339f75f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -3,12 +3,12 @@ current_version = 7, 0, 0, "alpha", 4 commit = False tag = False parse = (?P\d+)\,\ (?P\d+)\,\ (?P\d+)\,\ \"(?P\S+)\"\,\ (?P\d+) -serialize = +serialize = {major}, {minor}, {patch}, "{release}", {build} [bumpversion:part:release] optional_value = final -values = +values = alpha beta candidate diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..443353b32d --- /dev/null +++ b/.flake8 @@ -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, diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fad3516555..a4ad584bfd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,7 @@ jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v2 @@ -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 @@ -60,6 +61,7 @@ jobs: install: needs: [build] runs-on: ${{ matrix.os }} + timeout-minutes: 10 strategy: fail-fast: false matrix: diff --git a/.github/workflows/buildutils.yml b/.github/workflows/buildutils.yml index 5f64ff1cba..2ac3edc735 100644 --- a/.github/workflows/buildutils.yml +++ b/.github/workflows/buildutils.yml @@ -16,6 +16,7 @@ concurrency: jobs: versioning: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v2 @@ -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.0a24,<5" hatch jlpm jlpm run build @@ -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.0a2t,<5" pip jlpm jlpm run build diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index 090e823abd..a76a88a82d 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -15,6 +15,7 @@ concurrency: jobs: check_release: runs-on: ubuntu-latest + timeout-minutes: 30 strategy: matrix: group: [check_release, link_check] diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 78417689b6..a979575ffa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -11,6 +11,7 @@ concurrency: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v2 @@ -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 diff --git a/.github/workflows/ui-tests.yml b/.github/workflows/ui-tests.yml index 79217cfe0a..855d53fec2 100644 --- a/.github/workflows/ui-tests.yml +++ b/.github/workflows/ui-tests.yml @@ -24,6 +24,7 @@ jobs: ui-tests: needs: [build] runs-on: ubuntu-latest + timeout-minutes: 10 strategy: fail-fast: false matrix: @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8be5437870..dc029d2560 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -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: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e506ced66e..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,28 +0,0 @@ -include LICENSE -include *.md -include pyproject.toml -include setup.py -include jupyter-config/notebook.json - -include package.json -include install.json -include ts*.json - -recursive-include tests * - -graft notebook/labextension -graft notebook/static -graft notebook/templates - -# Javascript files -graft src -graft style -prune **/node_modules -prune lib - -# Patterns to exclude from any directory -global-exclude *~ -global-exclude *.pyc -global-exclude *.pyo -global-exclude .git -global-exclude .ipynb_checkpoints diff --git a/buildutils/src/utils.ts b/buildutils/src/utils.ts index 777e7bd95e..de98bd3e5b 100644 --- a/buildutils/src/utils.ts +++ b/buildutils/src/utils.ts @@ -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]; } diff --git a/pyproject.toml b/pyproject.toml index 8750af9938..f65d5902ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,32 +1,109 @@ [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 = "jupyter@googlegroups.com" }, +] +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.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.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.hatch.build] +artifacts = [ + "notebook/labextension", + "notebook/static", + "notebook/schemas" +] + +[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", diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9cc6505ba8..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,77 +0,0 @@ -[metadata] -name = notebook -version = attr: notebook._version.__version__ -description = Jupyter Notebook - A web-based notebook environment for interactive computing -long_description = file: README.md -long_description_content_type = text/markdown -license_file = LICENSE -author = Jupyter Development Team -author_email = jupyter@googlegroups.com -url = https://github.com/jupyter/notebook -platforms = Linux, Mac OS X, Windows -project_urls = - Documentation = https://jupyter-notebook.readthedocs.io/ - Source = https://github.com/jupyter/notebook - Tracker = https://github.com/jupyter/notebook/issues -keywords = Jupyter, JupyterLab, Notebook -classifiers = - Intended Audience :: Developers - Intended Audience :: System Administrators - Intended Audience :: Science/Research - 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 - Framework :: Jupyter - -[options] -zip_safe = False -include_package_data = True -packages = find: -python_requires = >=3.7 -install_requires = - notebook_shim>=0.1,<0.2 - jupyterlab>=4.0.0a25,<5 - jupyterlab_server>=2.13,<3 - jupyter_server>=1.16.0,<2 - tornado>=6.1.0 - -[options.extras_require] -test = - coverage - nbval - pytest>=6.0 - pytest-cov - requests - pytest-tornasync - pytest-timeout - pytest-console-scripts - ipykernel - pre-commit - jupyterlab_server[test]>=2.13,<3 - -[options.packages.find] -exclude = - docs.* - tests - tests.* - -[options.entry_points] -console_scripts = - jupyter-notebook = notebook.app:main - -[flake8] -ignore = E501, W503, E402 -builtins = c, get_config -exclude = - .cache, - .github, - docs, - setup.py -enable-extensions = G -extend-ignore = - G001, G002, G004, G200, G201, G202, - # black adds spaces around ':' - E203, diff --git a/setup.py b/setup.py deleted file mode 100644 index 1f0ec32fff..0000000000 --- a/setup.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -import subprocess -import sys -from pathlib import Path - -import setuptools - -HERE = Path(__file__).parent.resolve() - -# The name of the project -NAME = "notebook" - -labext_name = "@jupyter-notebook/lab-extension" -lab_extension_dest = HERE / NAME / "labextension" -main_bundle_dest = HERE / NAME / "static" - -# Representative files that should exist after a successful build -ensured_targets = [ - str(lab_extension_dest / "static" / "style.js"), - str(main_bundle_dest / "bundle.js"), - str(HERE / NAME / "schemas/@jupyter-notebook/application-extension/package.json.orig"), -] - -data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_extension_dest), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), - ("share/jupyter/lab/schemas", f"{NAME}/schemas", "@jupyter-notebook/**/*"), - ( - "etc/jupyter/jupyter_server_config.d", - "jupyter-config/jupyter_server_config.d", - "notebook.json", - ), - ( - "etc/jupyter/jupyter_notebook_config.d", - "jupyter-config/jupyter_notebook_config.d", - "notebook.json", - ), -] - -try: - from jupyter_packaging import get_data_files, npm_builder, wrap_installers - - # In develop mode, just run yarn - builder = npm_builder(build_cmd="build", npm="jlpm", force=True) - - def post_develop(*args, **kwargs): - builder(*args, **kwargs) - try: - subprocess.run([sys.executable, "-m", "pre_commit", "install"]) - subprocess.run( - [sys.executable, "-m", "pre_commit", "install", "--hook-type", "pre-push"] - ) - except Exception: - pass - - cmdclass = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) - - setup_args = dict(cmdclass=cmdclass, data_files=get_data_files(data_files_spec)) -except ImportError: - setup_args = {} - - -if __name__ == "__main__": - setuptools.setup(**setup_args)