Skip to content

Commit

Permalink
Merge pull request #19 from python-project-templates/tkp/hf
Browse files Browse the repository at this point in the history
Fix library qualified name on windows
  • Loading branch information
timkpaine authored Jan 13, 2025
2 parents 27d4793 + 7ab9862 commit e6b3357
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 2 additions & 5 deletions hatch_cpp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,5 @@ def initialize(self, version: str, build_data: dict[str, t.Any]) -> None:

# force include libraries
for library in libraries:
if build_plan.platform.platform == "win32":
suffix = "dll"
else:
suffix = "so"
build_data["force_include"][f"{library.name}.{suffix}"] = f"{library.name}.{suffix}"
name = library.get_qualified_name(build_plan.platform.platform)
build_data["force_include"][name] = name
9 changes: 9 additions & 0 deletions hatch_cpp/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ class HatchCppLibrary(BaseModel):
export_symbols: List[str] = Field(default_factory=list, alias="export-symbols")
depends: List[str] = Field(default_factory=list)

def get_qualified_name(self, platform):
if platform == "win32":
suffix = "dll" if self.binding == "none" else "pyd"
elif platform == "darwin" and self.binding == "none":
suffix = "dylib"
else:
suffix = "so"
return f"{self.name}.{suffix}"


class HatchCppPlatform(BaseModel):
cc: str
Expand Down

0 comments on commit e6b3357

Please sign in to comment.