Skip to content

Commit

Permalink
Chore: use jupyter packaging (#600)
Browse files Browse the repository at this point in the history
* Chore: use jupyter_packaging

* Chore: remove setupbase

* Switch to hatch and hatch-jupyter-builder

* Convert version part to int

---------

Co-authored-by: Frederic Collonval <fcollonval@gmail.com>
  • Loading branch information
agoose77 and fcollonval committed Oct 14, 2023
1 parent 22a5846 commit 83a768f
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 980 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.

24 changes: 13 additions & 11 deletions nbdime/_version.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# 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(
int(groups["major"]),
int(groups["minor"]),
int(groups["micro"]),
_specifier_[groups.get("releaselevel", "")],
groups.get("serial", ""),
)
135 changes: 133 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,134 @@
[build-system]
requires = ["jupyterlab~=4.0", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5"]
build-backend = "hatchling.build"

[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"]

[project.urls]
"Homepage" = "https://nbdime.readthedocs.io"
"Bug Tracker" = "https://github.com/jupyter/nbdime/issues"
"Source" = "https://github.com/jupyter/nbdime"

[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.

27 changes: 0 additions & 27 deletions setup.cfg

This file was deleted.

0 comments on commit 83a768f

Please sign in to comment.