From 1d6c6659d9d8071b96a4eb503369f736f1af645f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 25 Sep 2022 20:28:05 -0500 Subject: [PATCH 1/6] convert to hatch --- MANIFEST.in | 62 -------------------- pyproject.toml | 155 +++++++++++++++++++++++++++++++++++++++++++------ setup.cfg | 73 ----------------------- setup.py | 64 +------------------- 4 files changed, 139 insertions(+), 215 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 3805dc076..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,62 +0,0 @@ -include *.md -include *.json -include *.txt - -include tasks.py -include .readthedocs.yaml -include .bowerrc -include mypy.ini -include codecov.yml -include yarn.lock - -include pytest.ini -include .coveragerc -include conftest.py -include playwright.config.ts - -# Lab extension files -graft nbgrader/labextension -graft src -graft style -graft schema -prune **/node_modules -prune lib - -# nbgrader format files -include nbgrader/nbgraderformat/*.json - -# nbextension files -recursive-include nbgrader/nbextensions * - -# doc files -recursive-include nbgrader/docs * -prune nbgrader/docs/build - -# static files and templates -recursive-include nbgrader/server_extensions/formgrader/static * -recursive-include nbgrader/server_extensions/formgrader/templates * - -# alembic files -include nbgrader/alembic.ini -recursive-include nbgrader/alembic * - -# tests files -include nbgrader/tests/apps/files/* -include nbgrader/tests/preprocessors/files/* -include nbgrader/tests/nbextensions/files/* -recursive-include nbgrader/tests/labextension_ui-tests * -# global exclusion -global-exclude *.pyc -global-exclude .ipynb_checkpoints -global-exclude __pycache__ -global-exclude .git -global-exclude *.pyo -global-exclude *~ - -# directories to prune -prune demos -prune tools -prune paper - -# binder files -prune binder diff --git a/pyproject.toml b/pyproject.toml index da2711028..21082a644 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,25 +1,144 @@ [build-system] -requires = ["jupyter_packaging~=0.12.0", "jupyterlab<4"] -build-backend = "jupyter_packaging.build_api" - -[tool.jupyter-packaging.options] -skip-if-exists = ["nbgrader/labextension/static/style.js"] -ensured-targets = ["nbgrader/labextension/static/style.js", "nbgrader/labextension/package.json"] - -[tool.jupyter-packaging.builder] -factory = "jupyter_packaging.npm_builder" - -[tool.jupyter-packaging.build-args] +requires = [ + "hatchling>=1.15.0", + "jupyterlab<4", +] +build-backend = "hatchling.build" + +[project] +name = "nbgrader" +description = "A system for assigning and grading notebooks" +readme = "README.md" +requires-python = ">=3.7" +authors = [ + { name = "Jupyter Development Team", email = "jupyter@googlegroups.com" }, +] +keywords = [ + "Grading", + "Homework", + "Jupyter", + "JupyterLab", + "Notebooks", +] +classifiers = [ + "", + "Framework :: Jupyter", + "Framework :: Jupyter :: JupyterLab", + "Framework :: Jupyter :: JupyterLab :: 3", + "Framework :: Jupyter :: JupyterLab :: Extensions", + "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +dependencies = [ + "alembic>=1.7", + "ipywidgets>=7.6", + "Jinja2>=3", + "jsonschema>=3", + "jupyter_client<8", + "jupyter_server>=1.12", + "jupyterlab<4", + "jupyterlab_server", + "MarkupSafe<2.2.0", + "nbclassic<0.4.0", + "nbclient>=0.6.1", + "nbconvert>=6", + "notebook>=6.4,<7", + "python-dateutil>=2.8", + "rapidfuzz>=1.8", + "requests>=2.26", + "sqlalchemy>=1.4,<2", + "traitlets<5.2.0", +] +version = "0.8.0" + +[project.license] +file = "LICENSE" + +[project.optional-dependencies] +dev = [ + "tbump", + "toml", +] +docs = [ + "myst-parser", + "sphinx", + "sphinx-autodoc-typehints", + "sphinx_rtd_theme", +] +tests = [ + "codecov", + "coverage", + "jupyter_packaging", + "nbval", + "pytest-cov", + "pytest-rerunfailures", + "pytest-tornasync", + "pytest-xdist==2.5.0", + "pytest==7.1.2", + "requests-mock", + "selenium>2.4,<4.3", + "wheel", +] + +[project.scripts] +nbgrader = "nbgrader.apps.nbgraderapp:main" + +[project.urls] +Homepage = "https://github.com/jupyter/nbgrader" + +[tool.hatch.build] +artifacts = [ + "nbgrader/labextension/", +] + +[tool.hatch.build.targets.wheel.shared-data] +"etc/jupyter/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d" +"etc/jupyter/jupyter_notebook_config.json" = "etc/jupyter/jupyter_notebook_config.json" +"nbgrader/labextension/static" = "share/jupyter/labextensions/nbgrader/static" +"install.json" = "share/jupyter/labextensions/nbgrader/install.json" +"nbgrader/labextension/package.json" = "share/jupyter/labextensions/nbgrader/package.json" +"nbgrader/labextension/schemas/nbgrader" = "share/jupyter/labextensions/nbgrader/schemas/nbgrader" + +[tool.hatch.build.hooks.jupyter-builder] +dependencies = [ + "hatch-jupyter-builder>=0.6.2", +] +build-function = "hatch_jupyter_builder.npm_builder" +ensured-targets = [ + "nbgrader/labextension/static/style.js", + "nbgrader/labextension/package.json", +] +skip-if-exists = [ + "nbgrader/labextension/static/style.js", +] + +[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs] +build_dir = "nbgrader/labextension" +source_dir = "src" +build_cmd = "install:labextension" +npm = [ + "jlpm", +] + +[tool.hatch.build.hooks.jupyter-builder.build-kwargs] build_cmd = "build:prod" -npm = ["jlpm"] - -[tool.check-manifest] -ignore = ["nbgrader/labextension/**", "yarn.lock"] +npm = [ + "jlpm", +] [tool.jupyter-releaser.hooks] -after-bump-version = ["python tools/post-bump.py"] -before-build-npm = ["python -m pip install 'jupyterlab<4'", "jlpm"] -before-build-python = ["jlpm clean:all"] +after-bump-version = [ + "python tools/post-bump.py", +] +before-build-npm = [ + "python -m pip install 'jupyterlab<4'", + "jlpm", +] +before-build-python = [ + "jlpm clean:all", +] [tool.tbump.version] current = "0.8.0" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cee80657b..000000000 --- a/setup.cfg +++ /dev/null @@ -1,73 +0,0 @@ -[metadata] -name = nbgrader -version = attr: nbgrader._version.__version__ -description = A system for assigning and grading notebooks -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/nbgrader -platforms = Linux, Mac OS X, Windows -keywords = Jupyter, Notebooks, Grading, Homework, JupyterLab -classifiers = - License :: OSI Approved :: BSD License - Programming Language :: Python - Programming Language :: Python :: 3 - - Framework :: Jupyter - Framework :: Jupyter :: JupyterLab - Framework :: Jupyter :: JupyterLab :: 3 - Framework :: Jupyter :: JupyterLab :: Extensions - Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt - -[options] -include_package_data = True -packages = find: -python_requires = >=3.7 -install_requires = - sqlalchemy>=1.4,<2 - python-dateutil>=2.8 - notebook>=6.4,<7 - nbconvert>=6 - requests>=2.26 - jsonschema>=3 - alembic>=1.7 - rapidfuzz>=1.8 - Jinja2>=3 - MarkupSafe<2.2.0 - jupyter_client<8 - jupyter_server>=1.12 - ipywidgets>=7.6 - nbclient>=0.6.1 - traitlets<5.2.0 - jupyterlab<4 - jupyterlab_server - nbclassic<0.4.0 - -[options.extras_require] -docs = - sphinx - sphinx_rtd_theme - sphinx-autodoc-typehints - myst-parser -tests = - pytest==7.1.2 - pytest-cov - pytest-rerunfailures - pytest-xdist==2.5.0 - pytest-tornasync - jupyter_packaging - coverage - selenium>2.4,<4.3 - codecov - nbval - requests-mock - wheel -dev = - tbump - toml - -[options.entry_points] -console_scripts = - nbgrader = nbgrader.apps.nbgraderapp:main diff --git a/setup.py b/setup.py index 18eb61af7..b6c668135 100644 --- a/setup.py +++ b/setup.py @@ -1,62 +1,2 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -from setuptools import setup -from jupyter_packaging import create_cmdclass -from pathlib import Path -import json -import sys -import os - -HERE = Path(__file__).parent.resolve() - -# Get the package info from package.json -pkg_json = json.loads((HERE / "package.json").read_bytes()) - -lab_path = (HERE / pkg_json["jupyterlab"]["outputDir"]) - -# Representative files that should exist after a successful build -ensured_targets = [ - str(lab_path / "package.json"), - str(lab_path / "static/style.js") -] - -labext_name = pkg_json["name"] - -data_files_spec = [ - # labextension installation - ("etc/jupyter/jupyter_server_config.d", "etc/jupyter/jupyter_server_config.d/", "*.json"), - # For backward compatibility with notebook server - ("etc/jupyter", "etc/jupyter/", "*.json"), - # labextension files - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"), -] - -setup_args = dict() - -if not os.getenv("NBGRADER_NO_LAB"): - try: - from jupyter_packaging import ( - wrap_installers, - npm_builder, - get_data_files - ) - - post_develop = npm_builder( - build_cmd="install:labextension", source_dir="src", build_dir=lab_path, npm="jlpm" - ) - setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) - setup_args["data_files"] = get_data_files(data_files_spec) - except ImportError as e: - import logging - logging.basicConfig(format="%(levelname)s: %(message)s") - logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.") - if not ("--name" in sys.argv or "--version" in sys.argv): - raise e - -if __name__ == "__main__": - setup(**setup_args) +# setup.py shim for use with applications that require it. +__import__("setuptools").setup() From 04d81b13f9b6955ece171258d77347a7476d8442 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 25 Sep 2022 20:45:24 -0500 Subject: [PATCH 2/6] switch to hatch backend --- pyproject.toml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 21082a644..39dc6eb62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "hatchling>=1.15.0", + "hatchling>=1.10.0", "jupyterlab<4", ] build-backend = "hatchling.build" @@ -21,7 +21,6 @@ keywords = [ "Notebooks", ] classifiers = [ - "", "Framework :: Jupyter", "Framework :: Jupyter :: JupyterLab", "Framework :: Jupyter :: JupyterLab :: 3", @@ -91,6 +90,22 @@ Homepage = "https://github.com/jupyter/nbgrader" [tool.hatch.build] artifacts = [ "nbgrader/labextension/", + "nbgrader/tests/", + "nbgrader/docs/", + "nbgrader/server_extensions/", +] + +[tool.hatch.build.targets.sdist] +include = [ + "/etc", + "/nbgrader", + "/schema", + "/src", + "/style", + "/*.*" +] +exclude = [ + "/.github", ] [tool.hatch.build.targets.wheel.shared-data] From fa74bb8a754eee8e46f0038833f4eb95298024f7 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 25 Sep 2022 20:51:57 -0500 Subject: [PATCH 3/6] handle NBGRADER_NO_LAB --- buildapi.py | 18 ++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 buildapi.py diff --git a/buildapi.py b/buildapi.py new file mode 100644 index 000000000..1831704db --- /dev/null +++ b/buildapi.py @@ -0,0 +1,18 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +# Custom build target that bails if NBGRADER_NO_LAB is set +import glob +import json +import os +import subprocess + +from hatch_jupyter_builder import npm_builder + + +def builder(target_name, version, *args, **kwargs): + + if os.getenv("NBGRADER_NO_LAB"): + return + + npm_builder(target_name, version, *args, **kwargs) diff --git a/pyproject.toml b/pyproject.toml index 39dc6eb62..cffd519d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,7 +120,7 @@ exclude = [ dependencies = [ "hatch-jupyter-builder>=0.6.2", ] -build-function = "hatch_jupyter_builder.npm_builder" +build-function = "buildapi.builder" ensured-targets = [ "nbgrader/labextension/static/style.js", "nbgrader/labextension/package.json", From f695a028f4f102064c12f9ddf5bf0e4e5fcaa4f4 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 25 Sep 2022 21:03:08 -0500 Subject: [PATCH 4/6] try with symlinked install --- tasks.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tasks.py b/tasks.py index 970bed344..c29764090 100755 --- a/tasks.py +++ b/tasks.py @@ -119,12 +119,7 @@ def js(args): def install(args): - # The docs don't seem to build correctly if it's a symlinked install. - if args.group == 'docs': - cmd = 'pip install .[docs,tests]' - else: - cmd = 'pip install -e .[tests]' - + cmd = 'pip install -e .[tests]' env = os.environ.copy() if args.group not in ['all', 'labextensions']: env['NBGRADER_NO_LAB'] = '1' From acdf3f90061811aeb8c90cc7ce7ab97464c54a8c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 25 Sep 2022 21:03:38 -0500 Subject: [PATCH 5/6] use editable mode for docs --- tasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index c29764090..e14fc31a4 100755 --- a/tasks.py +++ b/tasks.py @@ -119,7 +119,11 @@ def js(args): def install(args): - cmd = 'pip install -e .[tests]' + if args.group == 'docs': + cmd = 'pip install -e .[docs,tests]' + else: + cmd = 'pip install -e .[tests]' + env = os.environ.copy() if args.group not in ['all', 'labextensions']: env['NBGRADER_NO_LAB'] = '1' From bf47c618fa7e7a77adcb493fb5be457b03bddb59 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 25 Sep 2022 21:11:35 -0500 Subject: [PATCH 6/6] fix use of develop and update docs --- .../installation_developer.rst | 21 ++++--------------- .../labextension_ui-tests/run_jupyter_lab.py | 2 +- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/nbgrader/docs/source/contributor_guide/installation_developer.rst b/nbgrader/docs/source/contributor_guide/installation_developer.rst index c1de9aca4..1410d154a 100644 --- a/nbgrader/docs/source/contributor_guide/installation_developer.rst +++ b/nbgrader/docs/source/contributor_guide/installation_developer.rst @@ -25,24 +25,11 @@ We recommand using `conda environment