Open MycrofD opened 1 year ago
Unfortunately, we don't have binaries for Apple silicon yet which means that fastjet has to be compiled by pip locally. pyjet
doesn't compile the C++ FastJet library so it doesn't suffer from these failure cases. I don't have an M1 or M2 machine so I can't offer a lot of help but I believe some of the other devs have machines with Apple silicon so I think it is possible to install fastjet on them. The CGAL that is used here is within the container that pip is creating and, therefore, has nothing to do with what you have in your system. Is this the full error message? In theory, it should have a more detailed printout below. Can you post all of it?
The error message is more than 1300 lines. Here it is.
Can you try after installing the following?
brew install make gcc automake swig gmp mpfr boost
I had all of them installed already. I still did a brew reinstall make gcc automake swig gmp mpfr boost
just in case. Error message does not change.
Okay. Can you try the following just in case it works better?
git clone --recursive https://github.com/scikit-hep/fastjet.git
cd fastjet
pip install .
That also does not help. I get the same error.
FWIW I get the same error on my M1 MBP running latest Ventura. There's some messiness with the build environment I can't figure out. I ended up just building in a debian python container and bind-mounting fastjet!
It looks like it can't find the brew installed gmp. Perhaps something like the following could help
CXXFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip install .
However, we override these in setup.py...
If you are feeling brave you could add them to your local setup.py and try again with pip install .
@chrispap95 I tried the one with CXXFLAGS
but I see no difference, probably because this is overridden in setup.py as you pointed out.
I also edited the lines in setup.py
at env["CXXFLAGS"] = "-O3 -Bstatic -lgmp -Bdynamic -std=c++17" and "CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17",.
I still don't see any changes in the log.
I am afraid I can't do much since I don't have a machine with Apple silicon. Can you try the following? Just to see if it can find gmp.
cat >> test.c << "EOF"
#include <gmp.h>
int main(){return 0;}
EOF
gcc -o test test.c -lgmp
If the last line fails, then try with
gcc -o test test.c -I`brew --prefix gmp`/include -L`brew --prefix gmp`/lib
If this fails as well, then I have really no idea how to get this working.
I am afraid I can't do much since I don't have a machine with Apple silicon. Can you try the following? Just to see if it can find gmp.
cat >> test.c << "EOF" #include <gmp.h> int main(){return 0;} EOF gcc -o test test.c -lgmp
If the last line fails, then try with
Yes, the last line failed.
gcc -o test test.c -I`brew --prefix gmp`/include -L`brew --prefix gmp`/lib
This did not fail. So, maybe we know where the problem is?
If this fails as well, then I have really no idea how to get this working.
Okay, very interesting. So these flags seem to work but we need to figure out how to pass them to pip
. How did you add them to setup.py
? What I would expect to work is the following: https://github.com/scikit-hep/fastjet/blob/apple_silicon/setup.py
You could try this by changing to the branch apple_silicon
and trying again with pip install .
Hmm, this does not work. Here are the initial lines of the log I got.
It seems like this is related. https://github.com/microsoft/vcpkg/issues/15956
If the rest of the printout looks the same as before, then I have no idea what to try next, and without a machine available to experiment I can't go wild with trials to fix this. The solution that Lindsey provided doesn't look that bad. Maybe try that instead?
Thanks a lot @chrispap95 for the help. Do you have a sample docker-compose.yaml
@lgray for me to get started with?
docker run -it --rm --entrypoint=/bin/bash -v /path/to/fastjet:/root/fastjet python:3.10-bullseye
You'll have to apt install packages and such to build, you might want to make your own Dockerfile for sanity's sake. Since I was doing a one-off I didn't make one.
I recently got access to an Apple silicon (M2) machine that I can use for dev work as well. I haven't done local dev work on an Apple computer for about 12 years at this point (👴) so while I know that brew
seems to be the only feasible way to do dev work on a Mac I'm curious if it would be possible to setup a dev environment using only conda-forge. Hopefully some of you can tell me if this is a terrible idea or not.
At the moment I have a dev-macosx-arm64-environment.yml
that I'm working on expanding
name: fastjet-dev
channels:
- conda-forge
dependencies:
- python=3.11
- autoconf
- automake
- cgal-cpp
- gmp
- libtool
- make
- patch
- pybind11
- swig
removal of the cgal
local download and setup from setup.py
- zip_filename = DIR / pathlib.Path(CGAL_ZIP).parts[-1]
-
- with urllib.request.urlopen(CGAL_ZIP) as http_obj:
- with open(zip_filename, "wb") as file_obj:
- shutil.copyfileobj(http_obj, file_obj)
-
- with zipfile.ZipFile(zip_filename) as zip_obj:
- cgal_dir = DIR / zip_obj.namelist()[0]
- zip_obj.extractall(DIR)
-
...
- f"--with-cgaldir={cgal_dir}",
and a build.sh
script to reset the state of the fastjet-core
submodule
#!/bin/bash
rm -rf CGAL-5.6*
rm -rf build
cd fastjet-core
git reset --hard fastjet-3.4.2
cd ..
python -m pip install --upgrade --verbose .
So far I'm failing extremely early
...
Detected Mac OSX
On Mac OSX, ./autogen.sh requires the GNU libtool and libtoolize scripts,
renamed glibtol and glibtoolize respectively by Apple to avoid
conflict with Apple-provided libtool.
They should be already installed, together with Apple developer tools,
in /usr/bin. If you see this message, they are not.
...
but I'm curious if this is possible at all to do with just conda-forge.
Trying to
pip install fastjet
on Mac M2, but getting errors like CGAL not found.Steps taken:
brew install cgal
. This installs CGAL 5.5.2.pip install --upgrade pip wheel
brew install cgal gmp wget
.But so far nothing helped. Any ideas?