thliebig / openEMS

openEMS is a free and open-source electromagnetic field solver using the EC-FDTD method.
http://openEMS.de
GNU General Public License v3.0
413 stars 146 forks source link

Python interface build process cannot find necessary headers #135

Closed aWZHY0yQH81uOYvH closed 5 months ago

aWZHY0yQH81uOYvH commented 8 months ago

Certain python distributions (namely the one provided by Homebrew on macOS) do not provide the system include paths when building the python bindings, resulting in build failure.

See https://github.com/thliebig/openEMS-Project/discussions/167#discussioncomment-7903125 for more details.

Possible fixes

Also https://github.com/thliebig/CSXCAD/issues/38

thliebig commented 8 months ago

I'm not sure this sounds like a viable solution. For example do I never use system include paths to build or install openEMS and dependencies. For example my default build command on Linux (and similar on Windows) looks like this: python setup.py build_ext -I/home/<username>/opt/include -L/home/<username>/opt/lib -R/home/<username>/opt/lib

In other words I always reference the full path to all includes and library locations. I would recommend doing something similar on macOS?

thliebig commented 8 months ago

This is btw also what I recommend in the readme inside the python folder

aWZHY0yQH81uOYvH commented 8 months ago

Perhaps then there should be a small change to the docs indicating that the "extended options" method may still need to be used even when everything is installed in /usr/local.

Additionally, on ARM64 macOS, I believe Homebrew installs stuff in /opt/Homebrew which may cause the same issue even if the default system include paths are not overwritten by the python environment.

I suppose all this would be resolved by using update_openEMS.sh but Homebrew is still the preferred option for macOS users.

Since this problem is mainly centered around Homebrew/macOS, should it get its own special snowflake documentation section? Or if the python install process is going to be inextricably linked (via the install path) to the main build process, which happens inside Homebrew, perhaps the brew formula should be updated to include the python installation (probably a good idea anyways)? Thoughts @biergaizi?

aWZHY0yQH81uOYvH commented 8 months ago

Adding the python bindings to the Homebrew formula to short circuit this entire problem looks pretty trivial: https://docs.brew.sh/Python-for-Formula-Authors#installing-bindings

thliebig commented 8 months ago

Personally I would prefer a solution in which the homebrew formula would solve this. This is exactly what the update_openEMS.sh does for building from source on Linux as well...

aWZHY0yQH81uOYvH commented 8 months ago

I agree. I'll put together a small PR soon to add the python bindings as an option in the Homebrew formula.

I apologize for being a bit naive about focusing on the default include paths since that was the difference between working and not for me.