Giter VIP home page Giter VIP logo

pywrap's Introduction

PyWrap

Build Status

Work in progress!

PyWrap is a C++ binding generator using pybind11, libclang and jinja. The main goal of this project is to automatically generate bindings for OCCT7.3 and beyond without single manual edit of the generated code. Once finished the project will be usable as a general C++ binding generator.

pywrap's People

Contributors

adam-urbanczyk avatar efferre79 avatar greyltc avatar jmwright avatar marcus7070 avatar nealie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pywrap's Issues

clang-13 support

Recently clang changed the format of the fake names for anonymous enums (llvm/llvm-project-staging@50542d5), breaking the anonymous detection workaround in EnumInfo.

Changing

if 'anonymous' in self.name:

to

if 'anonymous' in self.name or 'unnamed' in self.name:

seems to fix the problem, but I'm not sure if that's the way to go (and if anything else broke).

Methods returning non const references

Hi Friends,

As mentioned in this issue: CadQuery/OCP#121
Some OCCT methods return a read-write refererence, if it is an object it is ok, but when the reference is to a primitive type there is a problem to use that in python.

I need to use math_Matrix in an algorithm in python, but the c++ object is updated using non const references returned by auto operator(int, int) -> double&.

In C++:

void something(math_Matrix& m) {
  m(1,5) = 0.5;
}

In python this has no sense:

from OCP.math import math_Matrix

def something(m: math_Matrix):
  m(1,5) = 0.5

Same problem with math_Vector

Maybe methods like:

auto method(int i, int j) -> double&;

can be wraped as two methods like:

def method(i: int, j: int) -> float: ...
def method_s(i: int, j: int, f: float): ...

Embed cymbal [Which cymbal should be used?]

I'm still working on getting a port of CadQuery updated on FreeBSD using it's own pywrap generated code, which requires that everything that pywrap needs is also ported if not already present. In this case it's cymbal I'm working on.

Should I be using the cymbal code present in the PyPI or the CadQuery branch? I have based my port on the former so far, but the unit tests fail when it tried to monkey patch code where there is already code. Everything works and OCP seems to be generated properly, but the port will not be accepted if the tests fail and I do not have a good explanation why.

generating OCP natively

Hi,
after having got stuck with the virtualenv approach, see CadQuery/cadquery #1301 (closed), I'm trying to recap my original trials compiling ocp from source natively.
After having fiddled the setup for the path to clang, etc., the environment starts to pass the "bindgen" procedure. However, the compiler appears to have a problem with the generated code, where currently only the Standard module is being activated.
modules = ["Standard",

#"NCollection",
]
exclude = ["Standard_Handle.hxx","Standard",
...
"NCollection_Shared.hxx",
# added
#"Standard_MMgrOpt.hxx",
]
Consolidate compiler generated dependencies of target OCP
[ 16%] Building CXX object CMakeFiles/OCP.dir/OCP.cpp.o
[ 33%] Building CXX object CMakeFiles/OCP.dir/Standard.cpp.o
.../OCP/Standard.cpp: In function ‘void register_Standard(pybind11::module&)’:
.../OCP/Standard.cpp:751:22: error: expected primary-expression before ‘void’ 751 | (void ()( TPCallBackFunc ) ) static_cast<void ()( TPCallBackFunc ) >(&Standard_MMgrOpt::SetCallBackFunction),

Excluding the "Standard_MMgrOpt.hxx" produces an OCP module,

Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import OCP
OCP.
OCP.Standard OCP.Xw
OCP.Standard.Standard
OCP.Standard.Standard(
...
OCP.Standard.Standard_ImmutableObject(
...

Somehow, the "Standard_MMgrOpt.hxx" produces an Error. I suspect it has to do something with the typedef of "TPCallBackFunc" that may be not well interpreted by the compiler or resp. pybind, or maybe the wrapping inside my bindgen still has some issue, ...?
Though excluding "Standard_MMgrOpt.hxx" is by far not sufficient, because this very problem appears massively when reactivating the #"NCollection" line.

Now, I'm completely stuck. Code editing by hand, done during the first trials, is no option, of course.
I would need assistance in localizing the issue, at first bindgen or gcc with pybind11.
Eventually someone could publish or send the generated code inside OCP

ls ../OCP
CMakeLists.txt FindOpenCascade.cmake OCP.cpp OCP_specific.inc Standard.cpp Standard_pre.cpp Standard_tmpl.hxx Xw.cpp Xw_pre.cpp Xw_tmpl.hxx

I would be highly grateful for any hint or assistance. ...

gp.toml Has Hardcoded Path In It

The input_folder variable in gp.toml is hard coded to a user-specific path. I haven't been able to get the USER environment variable to work in the toml file yet, but am out of time for now. I'll try to circle back to this later today.

I also noticed that anaconda2 is used in the path, and only anaconda3 is available on my system.

Extend readme

  • High level schematic
  • Usage example
  • Few words on hacking

Cannot Build Conda Environment

The error I get is that the system package version required is not found.

$ conda env create -f ./env.yml -n pywrap
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound: 
  - system==5.8=2

I'm running Ubuntu 18.04 64-bit. Below is some Anaconda info. It is the Anaconda 2019.10 version.

$ conda list anaconda$
# packages in environment at /home/jwright/anaconda3:
#
# Name                    Version                   Build  Channel
anaconda                  custom                   py37_1

OCCT 7.3 Support

@adam-urbanczyk Is the plan with this to support OCE, or will it be based on OCCT? A lot of the FOSS community's concerns about OCCT have been addressed, and OCE seems to be falling behind update-wise. Also, what's the thought process behind creating this from scratch vs forking PyOCCT or PythonOCC?

opencascade folder and V7_4_0p1

I'm having a bit of trouble understanding why the opencascade folder and all that source is checked in to this repo. Have you made mods to it or something? Shouldn't fetching the occt source be a step in the setup?

This brings up another question, should I expect this to work on the most recent occt tag, V7_4_0p1?
Or should I only expect this to work on the V7_4_0 tag?
Or only on whatever thing is in the opencascade folder here?

VTK bindings?

Would it somehow be possible for the bindings of classes that inherit VTK classes (e.g., IVtkTools_ShapeDataSource) to also expose the VTK methods they inherit?

I'm not sure if this question belongs here or in the OCP repo.

Attempt to replicate... Fail

Tried to build.

zignig@noid:/opt/test_cq/pywrap$ ./run.sh
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/test_cq/pywrap/bindgen/main.py", line 95, in
main()
File "/home/zignig/.local/lib/python3.6/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/home/zignig/.local/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/zignig/.local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/zignig/.local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/zignig/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/zignig/.local/lib/python3.6/site-packages/click/decorators.py", line 27, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/opt/test_cq/pywrap/bindgen/main.py", line 29, in parse
settings,module_mapping,module_settings = read_settings(configuration)
File "/opt/test_cq/pywrap/bindgen/init.py", line 77, in read_settings
settings = toml.load(f)
File "/home/zignig/.local/lib/python3.6/site-packages/toml.py", line 108, in load
return loads(f.read(), _dict)
File "/home/zignig/.local/lib/python3.6/site-packages/toml.py", line 373, in loads
multibackslash)
File "/home/zignig/.local/lib/python3.6/site-packages/toml.py", line 478, in _load_line
value, vtype = _load_value(pair[1], _dict, strictly_valid)
File "/home/zignig/.local/lib/python3.6/site-packages/toml.py", line 608, in _load_value
raise TomlDecodeError("Stuff after closed string. WTF?")
toml.TomlDecodeError: Stuff after closed string. WTF?

perhaps we can have a build from source ? I don't mind waiting for a while to make.

'stddef.h' file not found

run.sh seems to complete, but I see a lot of errors similar to this earlier in the output.

[D 191211 08:42:02 module:23] ./opencascade/IFSelect_SelectSignature.hxx
[W 191211 08:42:02 header:36] ./opencascade/IFSelect_SelectSignature.hxx
[W 191211 08:42:02 header:37] /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/cstddef:50:10: fatal error: 'stddef.h' file not found
[D 191211 08:42:02 module:23] ./opencascade/IFSelect_SelectUnknownEntities.hxx
[W 191211 08:42:02 header:36] ./opencascade/IFSelect_SelectUnknownEntities.hxx
[W 191211 08:42:02 header:37] /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/cstddef:50:10: fatal error: 'stddef.h' file not found
[D 191211 08:42:03 module:23] ./opencascade/IFSelect_EditForm.hxx
[W 191211 08:42:03 header:36] ./opencascade/IFSelect_EditForm.hxx
[W 191211 08:42:03 header:37] /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/cstddef:50:10: fatal error: 'stddef.h' file not found

I tried installing clang since that seemed to be how most people solved a similar error, but that didn't help. @adam-urbanczyk Have you encountered this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.