-
Notifications
You must be signed in to change notification settings - Fork 46
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
fails to install on macos when USE_OMP=1 #51
Comments
Hi, The full check that you link to is |
It returns:
|
@Chrismarsh ok. Can you try testing the master branch on this repo, to see if this works better? |
@mraspaud worked for me in a fresh venv |
Ok then we need to make a new release |
I am running into this on apple clang 14 |
@cavemanloverboy Can you please provide more information? What version of Python? What version of pykdtree is being installed? What is the exact error including the traceback (if any) that shows up? |
Or...are you forcing USE_OMP (by specifying it as an environment variable) and then getting an error? |
I forced it and fixed it with the same flag |
What does your final install command look like (for future reference)? |
don't have it on hand but I just added |
@cavemanloverboy on macos 13.1 (arm64) with homebrew, I had to specify the libomp paths and fix the libomp library name for this to work. The total link needs to look like this:
I can write a PR targeting homebrew env if you want. |
@Chrismarsh If we can avoid it, I'd really like to not have something specific to an environment. The only reason conda was special-cased in the I'm surprised homebrew doesn't provide something that automatically includes the homebrew include/lib directories...but I guess that would require us/it to use its own provided compilers. I'll ask around at my work to see what other Mac developers use. Bottom line I'm ok with whatever we have to do, but it'd be nice if we can get it as generic as possible. I'd still like to default to not attempting an OpenMP if we aren't absolutely sure that it will work. Put another way, I'd rather get "pykdtree isn't as fast as you say" than "pykdtree can't be installed on OSX" issues. |
It looks like they changed how libomp is being installed as per Homebrew/homebrew-core#112107 (comment):
The following works if
Would you be open to adding a which could then be hinted via |
So it seems like everyone is having a different experience between the people in this thread and some coworkers who are trying some stuff out (@rayg-ssec). On @rayg-ssec's system he was able to specify setuptools/distutils CompilerFirst, let's go over some things I've learned (yes, I know distutils is being deprecated, but it was the easiest source to find):
Other examplesNext, I realized there is no way pykdtree is the only python package attempting to link to OpenMP so I did a github search and found some interesting strategies. Also, I think I've changed my mind on not doing anythign homebrew specific. If homebrew isn't automatically embedding the include and lib directories then that's not great, but if they exist then sure lets add them. Here are some of the examples I found: This one is interesting because they actually make a small/little C program and try to build it with certain flags to see what is available. This might be a hacky but good option to say "we're 95% sure these flags should work on this system, but if compilation fails for this simple program turn off OpenMP and warn the user". I saw at least one other package that attmepted this strategy of compiling a mini-program to determine supported flags. This one just has hardcoded flags for each platform. Other concernsI think no matter what is done the flags for OSX should not assume I think if we can code something up with the basic flags for each platform and maybe have a check for "are we using homebrew python and need addition includes/libs?" that would be a fine solution. I guess if it is overall an improvement then 👍. Let me know what the rest of you think? @mraspaud @storpipfugl and the rest of you in this issue. |
I noticed that if I had a stale No OMP base install
Uninstall and reinstall with omp "seems to work"
except that setup.py was modified to have garbage in the link line which means it cannot possibly have worked.
I git reset the
I think support homebrew and macports would be very welcome to macos users. Unhelpfully, to get around this in my python code I use CMake to directly determine compiler and library locations. |
Ok so @rayg-ssec sent me a diff that adds much better handling of clang versus gcc by changing the usage of I'm extremely behind on most of my real work projects, but as long as things go well tomorrow I should be able to make a PR for these changes tomorrow or this weekend. Then everyone here could give it a test hopefully. |
I wound up taking a swing at fully automating a default detection of brew/port openmp while maintaining backward compatibility and manual configurability between omp and gomp, but it could use some testers. In theory this is most easily checked with https://github.com/rayg-ssec/pykdtree/tree/feat-macos-libomp-automatic |
If people want to try this without cloning Ray's git manually, you should be able to do:
Edit: Fixed the username in the above URL |
The key line in the debug output notes the compiler category (unix), the omp/gomp selection, compiler flags, linker flags for OpenMP.
|
A quick confirmation check recipe... python3.11 -m venv --system-site-packages venv-pykdtree
source venv-pykdtree/bin/activate
pip install -v git+https://github.com/rayg-ssec/pykdtree.git@feat-macos-libomp-automatic
SOFILE="$(python -c 'from pykdtree import kdtree; print(kdtree.__file__)')"
echo $SOFILE
otool -L "$SOFILE" # will show libomp for macports case, but brew has static libomp
nm "$SOFILE" |grep omp # should show _.omp_ symbols for libomp, _omp_ for libgomp To try it with gcc (e.g. gcc-mp-12 from macports), substitute And to turn off openmp |
Seems to work for me (macos + brew)
I get
|
#83 has now been merged. I'm going to release a patch release in a little bit. Closing this as fixed. If you run into issues with these changes please file a new github issue with details on the errors you are receiving and your system/environment. |
This is now released as version 1.3.7 on PyPI: https://pypi.org/project/pykdtree/. This really only affects people installing with the A conda-forge update will come later, but there won't be any changes to how that binary package uses OpenMP. |
On macos
pip install pykdtree
fails due to how omp is added to the command lineMacOS requires the following omp invocation as detailed here
https://iscinumpy.gitlab.io/post/omp-on-high-sierra/
Alternatively, setting USE_OMP=0 by default on macos may be a better user experience.
edit: I should note that I see the setup.py code that checks for this. I am using a default install without conda. However, this seems to not be triggered correctly. Just checked the following:
The text was updated successfully, but these errors were encountered: