-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
This is more of a question born out of my own ignorance on Python's build internals. I would like to use extensionlib to build native extension modules interfaced with pybind11. There is a simple example of how to do this with setuptools + setup.py (and other build tools). I'm trying to figure out how to do this with extensionlib + hatch but I can't figure it out.
- Do I use the custom build hook to compile native extensions, or do I need to make my own build-hook plugin?
Something like:
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomHook(BuildHookInterface):
def initialize(self, version, build_data):
if self.target_name == 'wheel':
...- ...or does extensionlib scaffold these build hooks via entry-points? If I have something like this:
# pyproject.toml
...
[project.entry-points.extensions]
hatch_build = "my-pkg:ExampleExtensionModules"then this should instantiate a ExampleExtensionModules class in a hatch_build.py file, yes? And then build things with the build runner? Something like:
# hatch_build.py
from extension.runner import BuildRunner
from extension.interface import ExtensionModules
class ExampleExtensionModules(ExtensionModules):
def __init__(self, name: str, root: str, metadata: dict, config: dict):
super().__init__(name, root, metadata, config)
runner = BuildRunner('.', ...)
....
def inputs():
return(["src/my_pkg/ext/"]) # this stores my __init__.py + extension module source files
....I can't seem to parse how to connect the build script with the pyproject.toml file / with hatch build; hatch build --ext silently returns without error and without building anything in the simple example I'm trying to get going now.