mhogg / pyoctree

Octree structure containing a 3D triangular mesh model
MIT License
86 stars 19 forks source link

Compiling fails on MacOS #18

Closed schlegelp closed 7 years ago

schlegelp commented 7 years ago

Hi! First off: love your package! I'm using it to determine if a point is within a volume abusing ray casting and it works like a charm. I encountered an error when compiling the package (see screenshot, MacOS). I was able to work around by painstakingly changing the default compiler but - for the sake of easy distribution - is there anything on your end you can do about this? Would maybe adding more wheels be an option?

screen shot 2017-08-24 at 14 40 17

mhogg commented 7 years ago

Hi Philipp,

Thanks. I have tried to address different compiler settings in the setup.py file. It works for linux and windows, but I haven't tested it on macosx as I don't have access. My setup.py file (which uses distutils) detects macosx as unix, so it doesn't have any specific macosx settings.

If you give me some more details, I might be able to update my setup.py to suit macosx. I see that you are using gcc via clang, which should accept the -fopenmp flag ok (according to https://stackoverflow.com/questions/35134681/installing-openmp-on-mac-os-x-10-11). So, what did you change to get it working? Did you just remove the fopenmp flag so you are not using openmp? Or are you using a different compiler (which one)? Or is that flag called something else on your system? For example, it is /openmp on windows.

Cheers, Michael

schlegelp commented 7 years ago

Hi Michael,

To be honest, I got it to work after lots of tinkering. If I remember correctly, the problem might have been that Anaconda ships with a different gcc/clang version - so I had to make it use the system's compiler. Let me try to reproducing this and I will get back to you.

Cheers, Philipp

schlegelp commented 7 years ago

OK, so the problem appears to be that Anaconda brings it's own compiler which does not support openmp. On a standard Python distribution your setup.py works like a charm. So one way is to force Anaconda to the standard compiler (a pain) or remove the openmp flag.

Might I suggest following in the footsteps of the guys from klustawik2: they mention the issue on their page and have their setup.py allow passing -no-openmp as argument?

mhogg commented 7 years ago

From Philipp (which somehow didn't get added to the issues):

Making these changing to setup.py did the trick for me: BUILD_ARGS['unix'] = [ ]
compilerLINK_ARGS['unix'] = [ ]

Michael's comment:

Thanks Philipp. Thanks for sending the link to klustawik2. I might try to do something similar to them.

Cheers, Michael

DupontCai commented 7 years ago

Same from here, wish you fix the bug soon. Best, Dupont

image

mhogg commented 7 years ago

Hi DupontCai,

For now I might just remove all openmp compiler / linking flags from the setup.py file, similar to Philipp's fix above. That way, pyoctree will work on all systems. This should satisfy all Mac users whose gcc do not support openmp.

Shortly I will add a command line option to enable openmp if desired.

Cheers, Michael

mhogg commented 7 years ago

Hi Philipp, DupontCai,

I have created a branch called add_openmp_option which contains a modified setup.py file that should work out of the box for you. I will do some more testing before I merge it into the main branch, but for now you can replace your old setup.py file with this one.

To install pyoctree from source without openmp, use the command: python setup.py install

To install pyoctree from source with openmp (which means your compiler must support openmp), use the command: python setup.py install --openmp

Cheers, Michael

mhogg commented 7 years ago

Fixed in release 0.2.4.