smash-transport / smash-analysis

Analysis tools that are useful to calculate observables from SMASH.
http://theory.gsi.de/~smash/analysis_suite/current/
Other
8 stars 2 forks source link

Error while building with Apple M1 #53

Closed nilssass closed 2 years ago

nilssass commented 2 years ago

While building smash-analysis I get an error from cmake. It seems to origin from FloatMath.

This is the error:

CMake Error at test/FOPI_pions/CMakeLists.txt:46 (run_one_energy):
  run_one_energy Function invoked with incorrect arguments for function
  named: run_one_energy

My system:

-Apple M1 Chip -cmake version: 3.22.0

AxelKrypton commented 2 years ago

I could not reproduce the error on my MacBook Pro (with M1 chip). In particular, cloning, and running cmake -DSMASH_PATH=[...] .. from a build directory works fine.

However, just out of curiosity I read a bit of code here and there for the first time. I am not sure this is connected with your issue, but I noticed that https://github.com/smash-transport/smash-analysis/blob/253d38861928f336c436bc9cf14d9a1c9e962108/cmake/FloatMath.cmake#L1-L7 makes use of python2 on line 2 and, at least, this is in contradiction with the statement of the README that

Python 2 is not supported anymore.

For sure, if you do not have any python2, something should go wrong, but I would be very surprised that

Just to rule it out you can run which python2 and see if you get an output and/or try to run something like

python2 -Sc "print 0.4 + 2*0.1"

which is what CMake is running underneath at some point.

If all looks good, please provide more detailed information of what you did from an empty build till the error.

gabriele-inghirami commented 2 years ago

Uuuuh, there are still two python2 instructions floating around...

g@uhuru:~/SMASH-dev/smash-analysis$ for i in $(find ./ -depth -name "*")
> do
> if [ ! -d $i ]
> then
> grep python2 $i
> fi
> done
0000000000000000000000000000000000000000 b77a8f7bbddc4f39f786713be9ad2c5014d9f3bc gabriele <inghirami@fias.uni-frankfurt.de> 1613418882 +0100   WIP on updates_python_3: 3cf2766 Changed python2->python in CMakeLists. Processed all scripts with 2to3-2.7.
300757838ff443f18d47fdfa334f48ba88e52444 3cf2766e68e75680bd22c7b06440569c8ad09e76 gabriele <inghirami@fias.uni-frankfurt.de> 1612743623 +0100   commit: Changed python2->python in CMakeLists. Processed all scripts with 2to3-2.7.
    execute_process(COMMAND "python2" "-Sc" "print ${expr}"
pythonpath=$(which python2)

Sorry, I will remove them and open a PR within a couple of hours...

nilssass commented 2 years ago

Now it works! I manually updated the specified python version to python3 in smash-analysis/cmake/FloatMath.cmake, line 2, and added parentheses around the argument of print:

function(float_math VAR expr)
    execute_process(COMMAND "python3" "-Sc" "print(${expr})"
                    OUTPUT_VARIABLE output
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
    set(${VAR} ${output} PARENT_SCOPE)
endfunction()

Thank you for the hint!

gabriele-inghirami commented 2 years ago

If it is solved, we can close the issue. :)