3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-10-09 01:11:58 +00:00

pyosys: globals, set operators for opaque types

There is so much templating going on that compiling wrappers.cc now takes 1m1.668s on an Apple M4…
This commit is contained in:
Mohamed Gaber 2025-09-23 03:44:34 +03:00
parent 384f7431fd
commit 54799bb8be
No known key found for this signature in database
9 changed files with 343 additions and 47 deletions

View file

@ -185,13 +185,12 @@ bool already_setup = false;
bool already_shutdown = false;
#ifdef WITH_PYTHON
// Include pyosys as a module so 'from pyosys import libyosys' also works
// in interpreter mode.
// Include pyosys as a package for some compatibility with wheels.
//
// This should not affect using wheels as the dylib has to actually be called
// pyosys.so for this module to be interacted with at all.
// pyosys.so for this function to be interacted with at all.
PYBIND11_MODULE(pyosys, m) {
m.add_object("libyosys", m.import("libyosys"));
m.add_object("__path__", py::list());
}
#endif
@ -209,7 +208,8 @@ void yosys_setup()
// initialized platform fails (such as when libyosys is imported
// from a Python interpreter)
if (!Py_IsInitialized()) {
PyImport_AppendInittab((char*)"libyosys", PyInit_libyosys);
PyImport_AppendInittab((char*)"pyosys.libyosys", PyInit_libyosys);
// compatibility with wheels
PyImport_AppendInittab((char*)"pyosys", PyInit_pyosys);
Py_Initialize();
PyRun_SimpleString("import sys");