ci: fix scss build on building

We add a custom hook to our sdist target, such that "make scss" is run
whenever we run `python -m build --sdist`.
This commit is contained in:
Régis Behmo 2025-04-16 16:34:17 +02:00
parent 269e06e935
commit 46f7d7af30
3 changed files with 12 additions and 5 deletions

View File

@ -3,11 +3,6 @@ variables:
TUTOR_PYPI_PACKAGE: tutor-deck TUTOR_PYPI_PACKAGE: tutor-deck
GITHUB_REPO: overhangio/tutor-deck GITHUB_REPO: overhangio/tutor-deck
build-css:
script:
- make scss
stage: build
include: include:
- project: "community/tutor-ci" - project: "community/tutor-ci"
file: "plugin-gitlab-ci.yml" file: "plugin-gitlab-ci.yml"

View File

@ -1,12 +1,20 @@
# https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/ # https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/
import os import os
import subprocess
import typing as t import typing as t
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.metadata.plugin.interface import MetadataHookInterface from hatchling.metadata.plugin.interface import MetadataHookInterface
HERE = os.path.dirname(__file__) HERE = os.path.dirname(__file__)
class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
# This runs before the build starts
subprocess.check_call(["make", "scss"])
class MetaDataHook(MetadataHookInterface): class MetaDataHook(MetadataHookInterface):
def update(self, metadata: dict[str, t.Any]) -> None: def update(self, metadata: dict[str, t.Any]) -> None:
about = load_about() about = load_about()

View File

@ -69,5 +69,9 @@ strict-naming = false
include = [ "/tutordeck", ".hatch_build.py"] include = [ "/tutordeck", ".hatch_build.py"]
exclude = ["tests*"] exclude = ["tests*"]
[tool.hatch.build.targets.sdist.hooks.custom]
# Build static assets prior to running sdist
path = ".hatch_build.py"
[tool.hatch.build.targets.wheel] [tool.hatch.build.targets.wheel]
packages = ["tutordeck"] packages = ["tutordeck"]