Last active
April 29, 2025 21:13
-
-
Save adrn/afd9222416e359fcef826b7988b7d69f to your computer and use it in GitHub Desktop.
Mac M4 EXP install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run a full compile of exp - see notes in other files | |
# originally sent by Mike P on Slack, modified by APW | |
# APW ran with uv to manage Python - in the EXPDIR: | |
# uv venv --python 3.12 | |
# source .venv/bin/activate | |
# expui/CMakeLists.txt | |
# pyEXP/CMakeLists.txt | |
# both need to comment out these lines: | |
# target_compile_options(pyEXP PUBLIC ${OpenMP_CXX_FLAGS}) | |
# to avoid a -fopenmp -Xclang error (pls sort this sometime) | |
# Make sure to install the dependencies with homebrew: | |
# brew install fftw gsl open-mpi hdf5 libomp libpng eigen | |
export HOMEDIR=/Users/aprice-whelan/ | |
export EXPDIR=${HOMEDIR}/projects/exp | |
mkdir -p ${EXPDIR}/build | |
cd ${EXPDIR}/build | |
# This is a safer way to get the path to the python executable that works even within a | |
# virtual environment: | |
export PYTHON_BASE=$(python -c "import sys; print(sys.base_prefix)") | |
export PYTHON_EXEC=${PYTHON_BASE}/bin/python3.12 | |
export PYTHON_LIBRARY=${PYTHON_BASE}/lib/libpython3.12.dylib | |
echo "Using Python at: ${PYTHON_BASE}" | |
export BREWHOME=/opt/homebrew/Cellar/ | |
export FFTW3_HOME=${BREWHOME}/fftw/3.3.10_2/ | |
export GSL_HOME=${BREWHOME}/gsl/2.8 | |
export MPI_HOME=${BREWHOME}/open-mpi/5.0.7/ | |
export HDF5_HOME=${BREWHOME}/hdf5/1.14.6/ | |
#export OMP_HOME=${BREWHOME}/libomp/19.1.5/ | |
export OMP_HOME=${BREWHOME}/libomp/20.1.2/ | |
export PNG_HOME=${BREWHOME}/libpng/1.6.47/ | |
# should add a diagnostic here to make sure everyone is the correct path! | |
export PATH=${HOMEDIR}/bin/:/opt/homebrew/bin:/opt/homebrew/sbin:${MPI_HOME}/bin:${GSL_HOME}/bin:${FFTW3_HOME}/bin:${HDF5_HOME}/bin:$PATH | |
# OMP CANNOT be added here for some reason. It is fine to pass along as part of the compile flags | |
export LD_LIBRARY_PATH=${HOMEDIR}/lib/:${MPI_HOME}/lib:${GSL_HOME}/lib:${FFTW3_HOME}/lib:${HDF5_HOME}/lib:${PNG_HOME}/lib:$LD_LIBRARY_PATH | |
export INCLUDE=${HOMEDIR}/include/:${MPI_HOME}/include:${GSL_HOME}/include:${FFTW3_HOME}/include:${HDF5_HOME}/include:${PNG_HOME}/include:$INCLUDE | |
export LDFLAGS="-L${OMP_HOME}lib" | |
export CPPFLAGS="-I${OMP_HOME}include" | |
cmake -DMPI_ROOT=${MPI_HOME} -DCMAKE_C_COMPILER=${MPI_HOME}bin/mpicc -DCMAKE_CXX_COMPILER=${MPI_HOME}bin/mpicxx -DHDF5_ROOT=${HDF5_HOME} -DENABLE_NBODY=on -DENABLE_USER=on -DENABLE_PYEXP=on -DCMAKE_INSTALL_PREFIX=${BREWHOME} -DPYTHON_EXECUTABLE=${PYTHON_EXEC} -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DOpenMP_CXX_INCLUDE_DIR=/opt/homebrew/opt/libomp/include -DOpenMP_C_INCLUDE_DIR=/opt/homebrew/opt/libomp/include .. | |
make -j 8 | |
make install | |
install_name_tool -add_rpath ${BREWHOME}lib ${BREWHOME}bin/exp | |
install_name_tool -add_rpath ${BREWHOME}lib ${BREWHOME}bin/cylcache | |
# add more here...? | |
# Add the pyEXP dir as a pyEXP.pth file in site-packages: | |
echo ${EXPDIR}/build/pyEXP/pyEXP.cpython-312-darwin.so > ${PYTHON_BASE}/lib/python3.12/site-packages/pyEXP.pth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment