Skip to content
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

pip install can't find proper boost directory #252

Closed
peijin94 opened this issue Dec 3, 2023 · 9 comments
Closed

pip install can't find proper boost directory #252

peijin94 opened this issue Dec 3, 2023 · 9 comments

Comments

@peijin94
Copy link

peijin94 commented Dec 3, 2023

On MacOS 14.1.1 M2
the installation command python -m pip install python-casacore returns error message of:

clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/Users/peijinz/lofarsun/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c src/fit.cc -o build/temp.macosx-14-arm64-cpython-311/src/fit.o -std=c++11
      src/fit.cc:28:10: fatal error: 'boost/python.hpp' file not found
      #include <boost/python.hpp>
               ^~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

Have installed boost with brew install boost
Tried --no-binary option, still getting the same error

@gmloose
Copy link
Collaborator

gmloose commented Dec 4, 2023

The current setup.py is a bit "stupid" and quite Linux-oriented (rework is planned). You may want to set the environment variable LD_LIBRARY_PATH to the path containing the Boost libraries. That should help finding the right libs.

@tammojan
Copy link
Contributor

tammojan commented Dec 4, 2023

Instead of 'stupid' I'd say the current system is 'primitive' :) The compiler is missing an include, so rather than LD_LIBRARY_PATH (which on MacOS is called DYLD_LIBRARY_PATH), it is probably better to do something like export CPATH=/path/to/boost_includes (without the boost part), or export CXXPATH=/path/to/boost_includes. Sorry this is so hard. I have not installed casacore on my own M1 yet.
@ludwigschwardt recently mentioned he may have improvements for MacOS packaging (also through cibuildwheels).

@gmloose
Copy link
Collaborator

gmloose commented Dec 4, 2023

I don't want to quibble, but setting LD_LIBRARY_PATH might still be a good idea, or even necessary, because setup.py uses that variable to extend the search path for libraries. I'm not sure if setting CPATH and CXXPATH suffices, but I also cannot test this, because I don't have a Mac at hand.

ludwigschwardt added a commit that referenced this issue Dec 4, 2023
In the grand old days, Homebrew installed to `/usr/local` and all was well.
Now, however, while Intel Homebrew still does this, Apple Silicon / M1 / M2
Homebrew has gone and picked a new prefix: `/opt/homebrew`. A good explanation
of the rationale is at https://earthly.dev/blog/homebrew-on-m1/. Basically,
Homebrew had to admit that Fink and MacPorts were right. :-P

The solution is to call `brew --prefix` and add those libraries explicitly
to the search list. Keep going if brew is not installed.

This addresses #252.
@ludwigschwardt
Copy link
Contributor

Hi, I fixed this a while ago in my cibuildwheel branch, but never committed the code 😅 I've made a PR. Peijin, could you check if it works for you?

tammojan pushed a commit that referenced this issue Dec 4, 2023
In the grand old days, Homebrew installed to `/usr/local` and all was well.
Now, however, while Intel Homebrew still does this, Apple Silicon / M1 / M2
Homebrew has gone and picked a new prefix: `/opt/homebrew`. A good explanation
of the rationale is at https://earthly.dev/blog/homebrew-on-m1/. Basically,
Homebrew had to admit that Fink and MacPorts were right. :-P

The solution is to call `brew --prefix` and add those libraries explicitly
to the search list. Keep going if brew is not installed.

This addresses #252.
@peijin94
Copy link
Author

peijin94 commented Dec 5, 2023

I can confirm I have the directory /opt/homebrew/include/boost/
But still, it shows the can't find boost/python.hpp error.
Should I set -L -I manually before pip install

@tammojan
Copy link
Contributor

tammojan commented Dec 5, 2023

You could have a look at the setup.py, where it specifies the include path and library path, and hack in your local directories there.

@peijin94
Copy link
Author

peijin94 commented Dec 5, 2023

python setup.py in the newest master branch commit.

Still have boost/python.hpp not found error.
Strange that it doesn't show the "boost not installed error"

@ludwigschwardt
Copy link
Contributor

ludwigschwardt commented Dec 5, 2023

I would do python -m build if you want to go the modern route.

On my machine it finds boost but complains about standard library include files:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdlib:90:5:
error: <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header.

This usually means that your header search paths are not configured properly.
The header search paths should contain the C++ Standard Library headers before
any C Standard Library, and you are probably using compiler flags that make that
not be the case.

I'll see if I can fix that too (although I suspect it's a problem confined to my computer 🙂 ).

gmloose pushed a commit that referenced this issue Dec 15, 2023
In the grand old days, Homebrew installed to `/usr/local` and all was well.
Now, however, while Intel Homebrew still does this, Apple Silicon / M1 / M2
Homebrew has gone and picked a new prefix: `/opt/homebrew`. A good explanation
of the rationale is at https://earthly.dev/blog/homebrew-on-m1/. Basically,
Homebrew had to admit that Fink and MacPorts were right. :-P

The solution is to call `brew --prefix` and add those libraries explicitly
to the search list. Keep going if brew is not installed.

This addresses #252.
@gmloose
Copy link
Collaborator

gmloose commented Feb 8, 2024

Was fixed by #253 and #255

@gmloose gmloose closed this as completed Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants