trelau / pyOCCT

Python bindings for OpenCASCADE via pybind11.
GNU Lesser General Public License v2.1
215 stars 45 forks source link

compiling XwWindow on osx #19

Open jf--- opened 6 years ago

jf--- commented 6 years ago

Hi,

I'm trying to compile pyocct on osx. So far, so good, though compilation trips over XwWindow.

This is probably due to linking to Xw_Window rather than Cocoa_Window PythonOCC does conditional compilation like so for the visualization module:

#ifdef WNT
  #include <windows.h>
  #include <WNT_WClass.hxx>
  #include <WNT_Window.hxx>
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
  #include <Cocoa_Window.hxx>
#else
  #include <Xw_Window.hxx>
#endif

Perhaps this could be carried over as:

#include <pyOCCT_Common.hpp>

#include <xTypes.h>

#include <Aspect_DisplayConnection.hxx>
#include <Aspect_FBConfig.hxx>
#include <Aspect_Window.hxx>

#ifdef WNT
  #include <WNT_Window.hxx>
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
  #include <Cocoa_Window.hxx>
#else
  #include <Xw_Window.hxx>
#endif

#include <Xw_Window.hxx>

Which brings me to my question; would by extension the class definition look like so? ( I'm new to pybinder11 and not a c++ programmer... go easy on me ;)


   #ifdef WNT
     py::class_<Xw_Window, opencascade::handle<WNT_Window>, Aspect_Window>(mod, "Xw_Window", "This class defines XLib window intended for creation of OpenGL context.")
   #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
     py::class_<Xw_Window, opencascade::handle<Cocoa_Window>, Aspect_Window>(mod, "Xw_Window", "This class defines XLib window intended for creation of OpenGL context.")
   #else
     py::class_<Xw_Window, opencascade::handle<Xw_Window>, Aspect_Window>(mod, "Xw_Window", "This class defines XLib window intended for creation of OpenGL context.")
   #endif

I'm a little surprised, since seeing pyocct up and running on windows, which should run into the same compilation issue I figure. Any pointer to how this works currently is much appreciated.

Finally, this thread on conda-forge was very helpful ( MacOSX10.9.sdk pointer ). That said, should those improvements to the conda recipe not be carried over to this repo?


Finally, the viewer is doing a similar conditional ( pyocct ) import. For conditional WNT / Xw / Cocoa Window instantiating see this

trelau commented 6 years ago

Good catch. I think there was some contributions similar to this for XwWindow: https://github.com/LaughlinResearch/pyOCCT/commit/f15d989812d14ca423eeebefc1ebed10f216408c

So yes I think something can be done for osx. I just don't have an osx platform to test on.

Regarding the conda recipe: I started that but abandoned it because the build time was way beyond the limits for Appveyor and Travis (both were grateful enough to extend the build time to 3 hours I think for Laughlin Research, but I never asked for conda). I'm hoping that breaking out types into smaller files decreases build time and gets it under the conda-forge limit so the recipe can be finished (that is the current effort of the pyOCCT_binder for OCCT 7.3.0).

jf--- commented 6 years ago

XwWindow: f15d989

That's a very helpful pointer, thx...

ecause the build time was way beyond the limits for Appveyor and Travis (both were grateful enough to extend the build time to 3 hours I think for Laughlin Research, but I never asked for conda)

Thomas asked for a similar thing for pythonocc, on TravisCI.

Something really cool is that succesful compile's on master got uploaded to Thomas' conda account, which means that there's then very little overhead keeping up with changes in master. I could look into porting that?

trelau commented 6 years ago

CI integration hasn't been fully built out, so that would be a great next step. I think it makes sense to upload successful master builds to my account, and eventually I'd like to get conda-forge builds for releases.

trelau commented 4 years ago

@jf--- master branch is updated to occt 7.4.0 (and smesh) and CI for windows and linux py 3.6 to 3.8. i experimented with osx support but didn't get the CI stuff right and hard to do since i don't have that platform locally to quickly debug.

if you're interested, i have a branch i could push with some github actions for osx if you want to give it a shot and/or provide some feedback. but even just building the bindings locally on osx would be a great help. actually...i'm going to push that osx branch but leave out the compile part, but it will generate the binding source. if you want, you can grab that and try and compile. any feedback or tweaks to the binding process would be great!

whophil commented 3 years ago

I'm interested in Mac builds and conda-forge. Is there still any interest in this, or has there been any movement? I can help out with both.

trelau commented 3 years ago

I would like to support OSX, but I work on Windows and find it tough and very slow to debug for other platforms since I have to rely on the Github Actions results. You'll note that in the Actions for this repo I do attempt to generate the bindings for OSX, but not compile. If you could attempt this locally and contribute that would be great!