From 831f3c709dfa39bb9ba8e61cbd50c624b3080270 Mon Sep 17 00:00:00 2001 From: Frederic Collonval Date: Sat, 14 Oct 2023 16:43:04 +0200 Subject: [PATCH] Switch to hatch and hatch-jupyter-builder --- .github/workflows/tests.yml | 4 +- MANIFEST.in | 40 ----------- nbdime/_version.py | 20 +++--- pyproject.toml | 137 +++++++++++++++++++++++++++++++++--- pytest.ini | 3 - setup.cfg | 112 ----------------------------- setup.py | 44 +----------- 7 files changed, 140 insertions(+), 220 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 pytest.ini delete mode 100644 setup.cfg diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45e3feab..61196bf3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -123,7 +123,7 @@ jobs: tmpdir=$(mktemp -d) echo "TEST_TMPDIR=$tmpdir" >> $GITHUB_ENV pushd $tmpdir - py.test -l --cov-report xml --cov=nbdime --pyargs nbdime + pytest -l --cov-report xml --cov=nbdime --pyargs nbdime - name: Test with pytest (Windows) if: startsWith(matrix.os, 'windows') run: | @@ -132,7 +132,7 @@ jobs: $hgconfig = "[ui]`r`nusername = CI " $hgconfig | Set-Content ($HOME + "\mercurial.ini") echo "TEST_TMPDIR=." >> $Env:GITHUB_ENV - py.test -l --cov-report xml --cov=nbdime --pyargs nbdime + pytest -l --cov-report xml --cov=nbdime --pyargs nbdime - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index f8eae42b..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,40 +0,0 @@ -include LICENSE.md -include CONTRIBUTING.md -include README.md - -include setupbase.py -include pytest.ini -include conftest.py - -# Documentation -graft docs -exclude docs/\#* - -# docs subdirs we want to skip -prune docs/build -prune docs/gh-pages -prune docs/dist - -# Webapp files -include lerna.json -include package.json -include tsconfig.json -include tsconfig_base.json -graft nbdime/webapp -graft packages -prune packages/*/coverage -prune packages/*/lib -prune packages/*/build -prune packages/*/node_modules -prune packages/*/test/build - -# Extension files -graft nbdime/labextension -graft nbdime/notebook_ext - -# Patterns to exclude from any directory -global-exclude *~ -global-exclude *.pyc -global-exclude *.pyo -global-exclude .git -global-exclude .ipynb_checkpoints diff --git a/nbdime/_version.py b/nbdime/_version.py index 48e4cea6..5aa9d468 100644 --- a/nbdime/_version.py +++ b/nbdime/_version.py @@ -1,21 +1,17 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +import re from collections import namedtuple VersionInfo = namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]) -version_info = VersionInfo(4, 0, 0, "alpha", 0) +_specifier_ = {"a": "alpha", "b": "beta", "rc": "candidate", "": "final"} -_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""} +__version__ = "4.0.0a0" -__version__ = "{}.{}.{}{}".format( - version_info.major, - version_info.minor, - version_info.micro, - ( - "" - if version_info.releaselevel == "final" - else _specifier_[version_info.releaselevel] + str(version_info.serial) - ), -) +parser = re.compile(r"^(?P\d+)\.(?P\d+)\.(?P\d+)((?Pa|b|rc)(?P\d+))?$") + +parsed_version = parser.match(__version__) +groups = parsed_version.groupdict() +version_info = VersionInfo(groups["major"], groups["minor"], groups["micro"], _specifier_[groups.get("releaselevel", "")], groups.get("serial", "")) diff --git a/pyproject.toml b/pyproject.toml index 3bfe7b53..5c175b68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,134 @@ [build-system] -requires = ["jupyter_packaging~=0.9.1", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"] -build-backend = "jupyter_packaging.build_api" +requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5"] +build-backend = "hatchling.build" -[tool.jupyter-packaging.builder] -factory = "jupyter_packaging.npm_builder" +[project] +name = "nbdime" +authors = [ + { name="Jupyter Development Team", email="jupyter@googlegroups.com" }, +] +description = "Diff and merge of Jupyter Notebooks" +readme = "README.md" +license = { file = "LICENSE.md" } +requires-python = ">=3.6" +classifiers = [ + "Framework :: Jupyter", + "Framework :: Jupyter :: JupyterLab", + "Framework :: Jupyter :: JupyterLab :: 4", + "Framework :: Jupyter :: JupyterLab :: Extensions", + "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +keywords = [ + "Interactive", + "Interpreter", + "Shell", + "Web", +] +dependencies = [ + "nbformat", + "colorama", + "pygments", + "tornado", + "requests", + "GitPython!=2.1.4,!=2.1.5,!=2.1.6 ", # For difftool taking git refs + "jupyter_server", + "jupyter_server_mathjax>=0.2.2", + "jinja2>=2.9", +] +dynamic = ["version"] -[tool.jupyter-packaging.options] -ensured-targets = ["nbdime/webapp/static/nbdime.js"] +[project.urls] +"Homepage" = "https://nbdime.readthedocs.io" +"Bug Tracker" = "https://github.com/jupyter/nbdime/issues" +"Source" = "https://github.com/jupyter/nbdime" -[tool.jupyter-packaging.build-args] -build_cmd = "build" +[project.scripts] +nbdime = "nbdime.__main__:main_dispatch" +nbshow = "nbdime.nbshowapp:main" +nbdiff = "nbdime.nbdiffapp:main" +nbdiff-web = "nbdime.webapp.nbdiffweb:main" +nbmerge = "nbdime.nbmergeapp:main" +nbmerge-web = "nbdime.webapp.nbmergeweb:main" +git-nbdiffdriver = "nbdime.vcs.git.diffdriver:main" +git-nbdifftool = "nbdime.vcs.git.difftool:main" +git-nbmergedriver = "nbdime.vcs.git.mergedriver:main" +git-nbmergetool = "nbdime.vcs.git.mergetool:main" +hg-nbdiff = "nbdime.vcs.hg.diff:main" +hg-nbdiffweb = "nbdime.vcs.hg.diffweb:main" +hg-nbmerge = "nbdime.vcs.hg.merge:main" +hg-nbmergeweb = "nbdime.vcs.hg.mergeweb:main" + +[project.optional-dependencies] +test = [ + "pytest>=6.0", + "pytest-cov", + "pytest-timeout", + "pytest-tornado", + "jupyter_server[test]", + "jsonschema", + "mock", + "notebook", + "requests", + "tabulate", +] +docs = [ + "sphinx", + "recommonmark", + "sphinx_rtd_theme", +] + +[tool.hatch.version] +path = "nbdime/_version.py" + +[tool.hatch.build.targets.sdist] +artifacts = [ + "docs", + "nbdime/labextension", + "nbdime/notebook_ext", + "nbdime/webapp/static", + "nbdime/webapp/template" +] +exclude = [".github", "binder", "node_modules"] + +[tool.hatch.build.targets.wheel] +artifacts = [ + "nbdime/webapp/static", + "nbdime/webapp/template" +] + +[tool.hatch.build.targets.wheel.shared-data] +"nbdime/notebook_ext" = "share/jupyter/nbextensions/nbdime" +"nbdime/labextension" = "share/jupyter/labextensions/nbdime-jupyterlab" +"jupyter-config" = "etc/jupyter" + +[tool.hatch.build.hooks.jupyter-builder] +dependencies = ["hatch-jupyter-builder>=0.5"] +build-function = "hatch_jupyter_builder.npm_builder" +ensured-targets = [ + "nbdime/labextension/static/style.js", + "nbdime/webapp/static/nbdime.js", +] +skip-if-exists = [ + "nbdime/labextension/static/style.js", + "nbdime/webapp/static/nbdime.js", +] + +[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs] source_dir = "packages" +build_dir = "nbdime/labextension" + +[tool.pytest.ini_options] +testpaths = "nbdime/tests" +norecursedirs = "node_modules" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 71b2de60..00000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -testpaths=nbdime/tests -norecursedirs=node_modules diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cb18d816..00000000 --- a/setup.cfg +++ /dev/null @@ -1,112 +0,0 @@ -[metadata] -name = nbdime -description = Diff and merge of Jupyter Notebooks -# long_description is set in setup.py -# long_description = file: README.md -long_description_content_type = text/markdown -url = https://nbdime.readthedocs.io -author = Jupyter Development Team -author_email = jupyter@googlegroups.com -license = BSD -license_file = LICENSE.md -platforms = - Linux - Mac OS X - Windows -classifiers = - Intended Audience :: Developers - Intended Audience :: System Administrators - Intended Audience :: Science/Research - License :: OSI Approved :: BSD License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Framework :: Jupyter -keywords = - Interactive - Interpreter - Shell - Web - -[options] -packages = find: -install_requires = - nbformat - colorama - pygments - tornado - requests - GitPython!=2.1.4,!=2.1.5,!=2.1.6 # For difftool taking git refs - jupyter_server - jupyter_server_mathjax>=0.2.2 - jinja2>=2.9 -python_requires = >=3.6 -include_package_data = True -zip_safe = False -scripts = - - -[options.package_data] -nbdime = tests/files/*.* - tests/filters/*.py - *.schema.json - webapp/static/*.* - webapp/templates/*.* - webapp/testnotebooks/*.* - labextension/*.* - labextension/schemas/nbdime-jupyterlab/*.* - labextension/static/*.* - notebook_ext/*.* - -[options.entry_points] -console_scripts = - nbdime = nbdime.__main__:main_dispatch - nbshow = nbdime.nbshowapp:main - nbdiff = nbdime.nbdiffapp:main - nbdiff-web = nbdime.webapp.nbdiffweb:main - nbmerge = nbdime.nbmergeapp:main - nbmerge-web = nbdime.webapp.nbmergeweb:main - git-nbdiffdriver = nbdime.vcs.git.diffdriver:main - git-nbdifftool = nbdime.vcs.git.difftool:main - git-nbmergedriver = nbdime.vcs.git.mergedriver:main - git-nbmergetool = nbdime.vcs.git.mergetool:main - hg-nbdiff = nbdime.vcs.hg.diff:main - hg-nbdiffweb = nbdime.vcs.hg.diffweb:main - hg-nbmerge = nbdime.vcs.hg.merge:main - hg-nbmergeweb = nbdime.vcs.hg.mergeweb:main - - -[options.extras_require] -test = pytest>=3.6; pytest-cov; pytest-timeout; pytest-tornado; jupyter_server[test]; jsonschema; mock; notebook; requests; tabulate -docs = sphinx; recommonmark; sphinx_rtd_theme - - -[bdist_wheel] -universal = False - -[flake8] -max-line-length = 140 -ignore = E123,E265,E261,E226,E241,E221,E251s - -[pep8] -max-line-length = 140 - -[manifix] -known-excludes = - .git* - .git/**/* - .coveragerc - .travis.yml - appveyor.yml - codecov.yml - lerna-debug.log - **/node_modules/**/* - **/__py_cache__/**/* - **/*.pyc - packages/**/coverage/**/* - packages/**/lib/**/* - packages/**/test/build/**/* - package-lock.json diff --git a/setup.py b/setup.py index 8185448d..75719bb6 100644 --- a/setup.py +++ b/setup.py @@ -3,46 +3,4 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -from jupyter_packaging import get_data_files, get_version -from setuptools import setup -import pathlib -import json - -HERE = pathlib.Path.cwd().absolute() - - -JUPYTER_SHARE_PATH = ( - pathlib.PurePath("share") - / "jupyter" -) - -JUPYTER_ETC_PATH = ( - pathlib.PurePath("share") - / "jupyter" -) - -NBDIME_PATH = HERE / "nbdime" - - -VERSION = get_version(NBDIME_PATH / '_version.py') - -with open(HERE / 'README.md') as f: - LONG_DESCRIPTION = f.read().replace( - 'docs/source/images', - 'https://github.com/jupyter/nbdime/raw/{version}/docs/source/images'.format(version=VERSION) - ) - - -if __name__ == '__main__': - setup( - version=VERSION, - long_description=LONG_DESCRIPTION, - data_files=get_data_files( - [ - (JUPYTER_SHARE_PATH / "nbextensions" / "nbdime", NBDIME_PATH / "notebook_ext", "*.js"), - (JUPYTER_SHARE_PATH / "lab" / "extensions", HERE / "packages" / "labextension" / "dist", "nbdime-jupyterlab-*.tgz"), - (JUPYTER_SHARE_PATH / "labextensions" / "nbdime-jupyterlab", NBDIME_PATH / "labextension", "**"), - (JUPYTER_ETC_PATH, HERE / "jupyter-config", "**/*.json") - ] - ) - ) +__import__("setuptools").setup()