mfem / PyMFEM

Python wrapper for MFEM
http://mfem.org
BSD 3-Clause "New" or "Revised" License
225 stars 62 forks source link

Install fails on MacOS: `chrpath` not found #213

Closed dohyun-cse closed 7 months ago

dohyun-cse commented 9 months ago

I just downloaded PyMFEM master branch and tried to install with python setup.py install. But it failed with chrpath command not found. python -m pip install mfem also fails with error: [Errno 2] No such file or directory: 'chrpath'.

I searched for chrpath package in mac, but it seems that it only supports Linux. An equivalent command can be

patchelf --set-rpath <rpath> <file>

where patchelf can be installed with brew install patchelf.

This patch works fine for both serial and parallel version when python setup.py install is used. But it still fails with pip install . (patchelf: not an ELF executable)...

I'm not that familiar with python wrappers, so I'm not sure whether I'm on a right path or not. Please let me know if I'm doing something wrong.

Also, I noticed that many examples are broken in the master branch, e.g.,

Is this because I'm using MacOS, or the examples are not tested before merging?


My device setting is

M1 Mac (14.2.1 (23C71)) Python 3.9.6 Swig 4.2.1 PyMFEM branch: master

andy9t7 commented 8 months ago

I also have the same problem as above. I have tried running both commands:

pip install mfem pip install mfem --no-binary mfem

sshiraiwa commented 8 months ago

I can not reproduce this error on my Mac. My operating system is older (Monterey), but I am suspecting this may relating to the version of setuptools, since in my environment, it does not call chrpath. I used python -m pip install ./

justinlaughlin commented 8 months ago

Okay, I did some digging into setup.py.

Thus, if wheel is installed and has bdist_wheel, setup.py will try to build a wheel, and will fail if chrpath is not installed.

Looking at the CI scripts:

@dohyun-cse and @andy9t7 can you try adding the flag haveWheel=False in setup.py after line 41 where it is set? I am guessing you are running into this error but @sshiraiwa is not because you already have wheel installed. This needs to be fixed and made more robust, but I don't believe building the wheel is necessary, so the easiest hot-fix for now is to just set the flag to False.

justinlaughlin commented 8 months ago

I think we should start moving towards libraries like scikit-build to help simplify some of the build logic.

dohyun-cse commented 7 months ago

Thank you @justinlaughlin for digging into this. I commented out the if statement and just set haveWheel=False, and tried to run

python setup.py install

In a fresh virtual environment with packages in requirements.txt, the above command installed mfem without any issues and examples run seamlessly. After installing mpi4py, I also succeeded to install its parallel version.