Skip to content

Commit

Permalink
Switch to hatch custom build (#238)
Browse files Browse the repository at this point in the history
* Switch to hatch custom build

* fix version bump
  • Loading branch information
blink1073 authored Apr 15, 2024
1 parent 5ec0ad6 commit 79d09bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
19 changes: 19 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""A custom hatch build hook for octave_kernel."""
import shutil
from pathlib import Path

from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class CustomHook(BuildHookInterface):
"""The octave_kernel build hook."""

def initialize(self, version, build_data):
"""Initialize the hook."""
here = Path(__file__).parent.resolve()
jupyter_data = here /"jupyter-data"
if jupyter_data.exists():
shutil.rmtree(jupyter_data)
jupyter_data.mkdir()
shutil.copy(here / "octave_kernel" / "kernel.json", jupyter_data / "kernel.json")
shutil.copytree(here / "octave_kernel" / "images", jupyter_data / "images")
27 changes: 5 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ content-type = "text/x-rst"
[project.optional-dependencies]
test = ["pytest", "nbconvert", "jupyter_kernel_test", "nbconvert"]

# Used to call hatch_build.py
[tool.hatch.build.hooks.custom]

[tool.hatch.build.targets.wheel.shared-data]
"jupyter-data/share" = "share"
"jupyter-data" = "share/jupyter/kernels/octave"

[tool.hatch.build.targets.sdist]
artifacts = ["jupyter-data"]
Expand All @@ -48,27 +51,7 @@ include = [

[tool.hatch.version]
path = "octave_kernel/_version.py"
source = "code"

[tool.jupyter-releaser]
skip = ["check-links"]

[tool.jupyter-releaser.hooks]
after-prep-git = ["make data-files"]

[tool.tbump.version]
current = "0.35.1"
regex = '''
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
((?P<channel>a|b|rc|.dev)(?P<release>\d+))?
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[tool.tbump.file]]
src = "octave_kernel/_version.py"
validate-bump = false

[tool.check-wheel-contents]
ignore = ["W002"]

0 comments on commit 79d09bf

Please sign in to comment.