Various build fixes, cleanup and details #6

Merged
leo merged 34 commits from trace into main 2023-11-21 15:32:49 +00:00
Showing only changes of commit 85693e99d0 - Show all commits

View File

@ -1,4 +1,5 @@
# noqa: INP001 # noqa: INP001
import shutil
import subprocess import subprocess
from hatchling.builders.hooks.plugin.interface import BuildHookInterface from hatchling.builders.hooks.plugin.interface import BuildHookInterface
@ -7,6 +8,15 @@ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomBuildHook(BuildHookInterface): class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data): def initialize(self, version, build_data):
super().initialize(version, build_data) super().initialize(version, build_data)
print("Building Cista frontend...") # A hack to stop building twice on run
subprocess.run("npm install --prefix frontend".split(" "), check=True) # noqa: S603 if not build_data.get("force_include"):
subprocess.run("npm run build --prefix frontend".split(" "), check=True) # noqa: S603 return
print("Building Cista frontend...", version, build_data)
npm = shutil.which("npm")
if npm is None:
raise RuntimeError(
"NodeJS `npm` is required for building Cista but it was not found"
)
frontend = "frontend"
subprocess.run([npm, "install", "--prefix", frontend], check=True) # noqa: S603
subprocess.run([npm, "run", "build", "--prefix", frontend], check=True) # noqa: S603