diff --git a/.gitignore b/.gitignore index 8ed6d62..491b39e 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,6 @@ dmypy.json # Yarn cache .yarn/ + +# This is generated by hatch +jupyterlab_blockly/_version.py diff --git a/jupyterlab_blockly/_version.py b/jupyterlab_blockly/_version.py deleted file mode 100644 index bf5dc8c..0000000 --- a/jupyterlab_blockly/_version.py +++ /dev/null @@ -1,23 +0,0 @@ -import json -from pathlib import Path - -__all__ = ["__version__"] - -def _fetchVersion(): - HERE = Path(__file__).parent.resolve() - - for settings in HERE.rglob("package.json"): - try: - with settings.open() as f: - version = json.load(f)["version"] - return ( - version.replace("-alpha.", "a") - .replace("-beta.", "b") - .replace("-rc.", "rc") - ) - except FileNotFoundError: - pass - - raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}") - -__version__ = _fetchVersion() diff --git a/pyproject.toml b/pyproject.toml index 94f4d4e..e3beed4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,9 @@ dev = [ [tool.hatch.version] source = "nodejs" +[tool.hatch.build.hooks.version] +path = "jupyterlab_blockly/_version.py" + [tool.hatch.metadata.hooks.nodejs] fields = ["description", "authors", "urls"] @@ -83,9 +86,7 @@ before-build-npm = [ ] before-build-python = [ # Build the assets - "jlpm build:prod", - # Clean the build artifacts to not include them in sdist - "jlpm clean" + "jlpm build:prod" ] [tool.check-wheel-contents]