Skip to content

Commit 6e4181e

Browse files
committed
wip
1 parent 65cc471 commit 6e4181e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/scyjava/_jvm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def is_awt_initialized() -> bool:
373373
return False
374374
Thread = scyjava.jimport("java.lang.Thread")
375375
threads = Thread.getAllStackTraces().keySet()
376-
return any(t.getName().startsWith("AWT-") for t in threads)
376+
return any(str(t.getName()).startswith("AWT-") for t in threads)
377377

378378

379379
def when_jvm_starts(f) -> None:

src/scyjava/_stubs/_hatchling.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Hatchling build hook for generating Java stubs."""
22

3+
import logging
34
import shutil
45
from pathlib import Path
56

@@ -9,6 +10,8 @@
910

1011
from scyjava._stubs._genstubs import generate_stubs
1112

13+
logger = logging.getLogger("scyjava")
14+
1215

1316
class ScyjavaBuildHook(BuildHookInterface):
1417
"""Custom build hook for generating Java stubs."""
@@ -17,20 +20,22 @@ class ScyjavaBuildHook(BuildHookInterface):
1720

1821
def initialize(self, version: str, build_data: dict) -> None:
1922
"""Initialize the build hook with the version and build data."""
20-
breakpoint()
2123
if self.target_name != "wheel":
2224
return
23-
dest = Path(self.root, "src")
24-
shutil.rmtree(dest, ignore_errors=True) # remove the old stubs
2525

26-
# actually build the stubs
27-
coord = f"{self.config['maven_coord']}:{self.metadata.version}"
26+
endpoints = self.config.get("maven_coordinates", [])
27+
if not endpoints:
28+
logger.warning("No maven coordinates provided. Skipping stub generation.")
29+
return
30+
2831
prefixes = self.config.get("prefixes", [])
29-
generate_stubs(endpoints=[coord], prefixes=prefixes, output_dir=dest)
32+
dest = Path(self.root, "src", "scyjava", "types")
3033

31-
# add all packages to the build config
32-
packages = [str(x.relative_to(self.root)) for x in dest.iterdir()]
33-
self.build_config.target_config.setdefault("packages", packages)
34+
# actually build the stubs
35+
generate_stubs(endpoints=endpoints, prefixes=prefixes, output_dir=dest)
36+
print(f"Generated stubs for {endpoints} in {dest}")
37+
# add all new packages to the build config
38+
build_data["artifacts"].append("src/scyjava/types")
3439

3540

3641
@hookimpl

0 commit comments

Comments
 (0)