-
Notifications
You must be signed in to change notification settings - Fork 72
Description
I really like cppimport for quick tests and local work. However, there's one irritating part I always have to look up:
/*
<%
setup_pybind11(cfg)
%>
*/This has two issues - one it's a special, parsed magic that requires changing the C++ code, and two, it's hard-coded into cppimport; if someone wanted to support something besides pybind11, it would need a new function like this. I'd like to propose a plugin system that allows pybind11 to declare what it needs for setup that could also be used elsewhere. I can help get the pybind11 part into the pybind11 package. :)
The idea I'm currently thinking of is the following. Users could use:
# Global
cppimport.plugin.pybind11.import_hook
import foobar
# Local
foobar = cppimport.plugin.pybind11.imp("foobar")
foobar = cppimport.plugin.pybind11.imp_from_filepath("src/foobar.cpp")It would be also available in cpp mode to support "classic" usage:
/*
<%
cppimport.plugin.pybind11.setup(cfg)
%>
*/A package (pybind11 in this case) would implement an entrypoint, cppimport.setup: pybind11 = .... When you access cppimport.plugin.<attr>, it looks for <attr> item in the cppimport.setup entry points. If found, it calls it with some to-be-determined API, possibly just "cfg" like the current setup_pybind11. No modification or special magic comments needed in the source code.
Thoughts? Also, a way to set config options would be important, which I haven't addressed above. I think import_hook could be replaced with something callable, like setup_import_hook, which would take cfg options. imp* could take configuration options too.