amusecode / amuse

Astrophysical Multipurpose Software Environment. This is the main repository for AMUSE
http://www.amusecode.org
Apache License 2.0
154 stars 98 forks source link

Could not build wheels for amuse-framework, which is required to install pyproject.toml-based projects #996

Closed Mohammad-Mardini closed 11 months ago

Mohammad-Mardini commented 11 months ago

Hello,

I am trying to install AMUSE on my macOS Ventura 13.4. I used MacPorts to install all of the prerequisites. I believe everything is installed properly. However, running pip install amuse-framework yields the following error:

ERROR: Could not build wheels for amuse-framework, which is required to install pyproject.toml-based projects

I tried to follow the suggestions listed in 911, but that didn't help. I would appreciate any suggestions from your side.

Thanks in advance!

LourensVeen commented 11 months ago

Hi Mohammad,

Just to check, you're installing into a virtualenv, not a Conda environment?

Unfortunately, it's not easy to get the build log when doing a pip install (see #449), so it's difficult to see what's going wrong. The best thing to do is probably to try a development install.

Do make sure that you remove any already installed amuse-* packages from the environment before doing the development install, as they will clash with the development install and cause errors. After that,

git clone https://github.com/amusecode/amuse.git
cd amuse
. /path/to/venv/bin/activate     # if not already active
pip install -e .
python setup.py develop_build

will probably give an error somewhere, given that it's not working, but it should produce a build.log file that you can attach here that will hopefully show us what's going wrong.

Mohammad-Mardini commented 11 months ago

Hi Lourens,

Thank you for your willingness to help. I got an error as below, however, I already tried to compile a simple "hello world" program and that worked smoothly.

checking for Fortran 77 libraries of g77... checking for dummy main to link with Fortran 77 libraries... none checking for Fortran 77 name-mangling scheme... configure: error: in /Users/mohammad/Documents/GitHub/amuse': configure: error: cannot compile a simple Fortran program Seeconfig.log' for more details

LourensVeen commented 11 months ago

Could you please attach the build.log file and the config.log file here, and I think we'll need config.mk as well? I know it looks like spam (and please post them as an attachment, not inline), but it's actually the information we need to figure out what the problem is :smile:.

Mohammad-Mardini commented 11 months ago

Here they are, however, I couldn't find the build.log.

config.log config.mk.txt

LourensVeen commented 11 months ago

Thanks! It seems to be finding a Fortran compiler at /usr/local/bin/g77 which won't run because it's for the wrong CPU type. Is it possible that you installed a Fortran compiler without MacPorts at some point, and that it was a Fortran compiler for an Intel Mac? Maybe something that was backed up from a previous machine and then restored on this one?

If you cannot easily remove that g77compiler, perhaps you could remove /usr/local/bin from your PATH when you try again? That should keep it from being found at least. I'm actually not entirely sure why we're first detecting gfortran and then also need to detect g77, but with a bit of luck getting the broken g77 out of the way things will work.

There's another problem in that it cannot find Cython, which I think is needed for compiling the workers. I cannot see from this where your Python comes from, but ideally it would be the one from MacPorts rather than the system Python. MacPorts has a py-cython package that you can install to make Cython available, but we'll probably get in trouble if we mix that with the system Python.

If you run ls -l /Users/mohammad/Amuse-env/bin/python* then you should see a link to /opt/local/bin/python, or something similar if you've got the MacPorts Python (I don't have a Mac, so I'm guessing a little bit). Could you try that and see what it says?

Mohammad-Mardini commented 11 months ago

I'm afraid that I didn't fully understand what do you mean by saying your PATH. Do you mean my .zshrc file? I don't have any thing that points to g77 in .zshrc file.

I got the following

lrwxr-xr-x 1 mohammad staff 7 Oct 8 11:48 /Users/mohammad/Amuse-env/bin/python -> python3 lrwxr-xr-x 1 mohammad staff 37 Oct 8 11:48 /Users/mohammad/Amuse-env/bin/python3 -> /Users/mohammad/anaconda3/bin/python3 lrwxr-xr-x 1 mohammad staff 7 Oct 8 11:48 /Users/mohammad/Amuse-env/bin/python3.10 -> python3

LourensVeen commented 11 months ago

g77

Sorry, I should have been clearer.

PATH is an environment variable that lists all the directories where the system should search for programs if you run a command. The configure script here tries to run the command g77, and when it does so the system will go through the list in PATH to try to find a corresponding program. You can type echo ${PATH} to see the current value of PATH. This will print a list of directories, separated by colons. One of those directories is /usr/local/bin, which is a standard directory to look into on UNIX systems like macOS. It's probably set in some system configuration file rather than in your .zshrc.

So what we want to do is to set the value of PATH to exactly that list, except that we omit the /usr/local/bin part, so that that directory won't be searched. You can set the value of an environment variable using the export command: export PATH="dir1:dir2:dir3" where the list of directories is the one printed by the echo command above, except that you don't put the /usr/local/bin part in.

Note that this will change the value of PATH only for your currently running terminal, so don't close the window, or if you do then you'll have to do this again.

Python

Ah, it seems that the Python you're using comes from Anaconda. Somehow, you must have had a conda environment active when you made the Amuse-env. We've had no end of problems with mixed MacPorts/Anaconda (or Homebrew/Anaconda) environments, so this is probably a bad idea.

To fix this, you'll need to recreate the Amuse-env environment without an Anaconda environment active. If you have Python 3.9 installed via MacPorts as instructed, then hopefully that will create a virtualenv with the right Python and Cython available.

Mohammad-Mardini commented 11 months ago

Thank you for your explanation! I have removed the cracked g77 file by running sudo rm -r and that helped to overcome the original issue. Then I created a new environment and made sure that my Anaconda was deactivated. Now I'm running python setup.py develop_build which seems to take ages. Is this normal? given that I have a monster MacBook with 64GB of RAM.

Also, I noticed an error regarding CUDA as below. Is that something that I can ignore?

make[1]: [dist/distributed-amuse.jar] Error 1 make: [src/dist/distributed-amuse.jar] Error 2 [03:22:11] building etics error in call, tail output: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Etics code CUDA_TK variable is not set to a valid path, please set the CUDA_TK variable to the directory where you installed CUDA the CUDA_TK directory must contain a bin directory with the executable make[1]: No rule to make target `raise_error'. Stop. make: [/NOCUDACONFIGURED] Error 2

LourensVeen commented 11 months ago

It can take quite a while to compile AMUSE, the build system doesn't parallelise things well, so it will only use one core. Hopefully we can improve on that in the future.

It looks like CUDA wasn't detected, do you have an nVidia GPU in your laptop? If not, then that makes sense. Any community codes that require CUDA will not be built, but the rest should still work in this case.

Mohammad-Mardini commented 11 months ago

Unfortunately, I have an intel graphics card. Also, the code currently is building mesa_r15140 so I think we can close this issue soon . Thank you so much for your time and prompt responses.

LourensVeen commented 11 months ago

Ah yes, mesa takes forever. Alright, let's hope it will all work now, if not just let me know and we'll debug some more.

You're welcome!