CadQuery / OCP

Apache License 2.0
93 stars 27 forks source link

pywrap does not work #130

Open gsohler opened 10 months ago

gsohler commented 10 months ago

Hi Following your documentation, i run:

pywrap -i /usr/include/clang/ -l /usr/lib64/libclang.so all ocp.toml but get this error finally:

clang.cindex.LibclangError: /usr/lib64/libclang.so: undefined symbol: clang_CXXMethod_isDeleted. Please ensure that your python bindings are compatible with your libclang.so version.

and I got few questions:

Thank you :)

adam-urbanczyk commented 10 months ago

CI says it does work. This tool is not really meant to be used by general public, better download release package with sources. If you really want to try, then take a look at the CI pipeline, but you'll be mostly on your own.

gsohler commented 10 months ago

Hi Adam, the shown error is mainly due to version mismatch, but this probably never happened to yo the CI pipeline.

I'd like to use cadquery_ocp in build123d and build123d in my openscad fork which understands python. (http://github.com/gsohler/openscad)

Now the issue is the openscad repeatedly starts and stops the python enginge(to make sure that there are no old results) python is quit with Py_FinalizeEx() but this issue is that this does not for the python modules which are linked with pywrap. if pywrap is derived from pybind11 it probably also has this problem:

if i start python the 2nd time from within the same program start, i get errors like: ImportError: generic_type: type "BRepLib_ShellError" is already registered!

issue, is that the generic type is still registerd in the pwrap/pybind11 To fix this, pywrap could replaced the saved type with the new type instead of throwing an error.

something like this in pybind11.h. what do you think ?

[gsohler@fedora pybind11]$ diff pybind11.h pybind11.h.fix 1355,1359d1354 < if ((rec.module_local ? get_local_type_info(rec.type) : get_global_type_info(rec.type)) < != nullptr) { < pybind11_fail("generic_type: type \"" + std::string(rec.name) < + "\" is already registered!"); < } 1381,1382c1376,1386 < if (rec.module_local) { < get_local_internals().registered_types_cpp[tindex] = tinfo;

auto &old_tinfo = (rec.module_local ? get_local_type_info(rec.type) : get_global_type_info(rec.type)); if (old_tinfo != nullptr) { // exist already if (self_value_and_holder) { self_value_and_holder.type->dealloc(self_value_and_holder); old_tinfo.dealloc(); //self_Value_and_holder.type = old_tinfo } oldinfo=tinfo; // pybind11_fail("generic_type: type \"" + std::string(rec.name) // + "\" is already registered!"); 1384,1385c1388,1394 < internals.registered_types_cpp[tindex] = tinfo; < }

      if (rec.module_local) {
          get_local_internals().registered_types_cpp[tindex] = tinfo;
      } else {
          internals.registered_types_cpp[tindex] = tinfo;
      }

}

adam-urbanczyk commented 10 months ago

It does not look like you need to regenerate the bindings, so just use the released sources. Regarding pybind11, I really don't know, try asking on their issue tracker. Quick search yields this: https://github.com/pybind/pybind11/issues/1925 , so you are probably out of luck.