Skip to content

Commit

Permalink
Switch to hatch and hatch-jupyter-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Oct 14, 2023
1 parent 9a2d44b commit 831f3c7
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 220 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -132,7 +132,7 @@ jobs:
$hgconfig = "[ui]`r`nusername = CI <CI@fake.com>"
$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 }}
Expand Down
40 changes: 0 additions & 40 deletions MANIFEST.in

This file was deleted.

20 changes: 8 additions & 12 deletions nbdime/_version.py
Original file line number Diff line number Diff line change
@@ -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<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)((?P<releaselevel>a|b|rc)(?P<serial>\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", ""))
137 changes: 129 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

112 changes: 0 additions & 112 deletions setup.cfg

This file was deleted.

44 changes: 1 addition & 43 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 831f3c7

Please sign in to comment.