Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pywrap does not work #130

Open
gsohler opened this issue Nov 27, 2023 · 3 comments
Open

pywrap does not work #130

gsohler opened this issue Nov 27, 2023 · 3 comments

Comments

@gsohler
Copy link

gsohler commented Nov 27, 2023

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:

  • which tool did output this error ? i could not find this text in the pywrap sources
  • What is this version equality about ? how can i check both versions and how can i best make sure that they are equal ?

Thank you :)

@adam-urbanczyk
Copy link
Member

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
Copy link
Author

gsohler commented Nov 27, 2023

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
Copy link
Member

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: pybind/pybind11#1925 , so you are probably out of luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants