-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add npm build step to pyproject.toml * Simplify github workflow * Apparently build is not installed by default * Try installing from wheels * Try just sdist builds? * Fix typo * Try custom script * Retry * Build the wheel again as well * Workflows wtf
- Loading branch information
Showing
4 changed files
with
78 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import subprocess | ||
import os | ||
from typing import Any | ||
import logging | ||
|
||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class NpmBuildHook(BuildHookInterface): | ||
@property | ||
def working_dir(self): | ||
return self.config.get("working_dir", ".") | ||
|
||
def initialize(self, version: str, build_data: dict[str, Any]) -> None: | ||
# if we can't build because we don't have the build dir, skip | ||
if not os.path.exists(self.working_dir): | ||
logger.info(f"Skipping npm build because {self.working_dir=} does not exist") | ||
return | ||
# if we don't need to build because we have all the artifacts, skip | ||
if all(os.path.exists(artifact) for artifact in self.config.get("artifacts", [])): | ||
logger.info(f"Skipping npm build because all artifacts exist") | ||
return | ||
subprocess.check_output( | ||
"npm install && npm run build", | ||
shell=True, | ||
cwd=self.working_dir) | ||
|
||
def clean(self, versions: list[str]) -> None: | ||
subprocess.check_output("npm run clean", shell=True, cwd=self.working_dir) |