Skip to content

Mac Installation Instructions

Bharat Medasani edited this page Sep 1, 2021 · 22 revisions

Mac installation instructions

Before installing simsopt, use a virtual environment either from conda or python3 venv. If using python3 venv, get openmpi and also python3 either through HomeBrew or MacPorts.

Macports

  1. Install macports. The installation instructions can be found here. (For catalina, you need to install xcode 11.5 and command line tools 11.5 to be compatible with macports)

  2. Install openmpi. Multiple versions of openmpi are avaialable. Here openmpi version that matches with clang11 is installed.

    sudo port install openmpi-clang11
    sudo port select --set mpi openmpi-clang11-fortran

    Installation of openmpi-clang11 also install python 3.9. Set this version of python3.9 as default python version.

    sudo port select --set python python39
    sudo port select --set python3 python39
  3. (Optional) Install wget, if you want to download simsopt source code as a zip file

    sudo port install wget

Python3 venv

Mac Catalina (10.15) comes with python 3.7, which can be accessed with python3 command. But we are using the python3.9 from macports. Assuming you ran the step 2 in Macports section

  1. Create a virtual environment named simsopt_ve using venv module
    python3 -m venv <path_where_you_want_the_venv>/simsopt_ve
  2. Activate the virtual environment.
    source <path_where_you_want_the_venv>/simsopt_ve/bin/activate
    After activating the virtual environment, (simsopt_ve) should appear in front of the command prompt.
  3. To confirm that simsopt_ve is activated, run which python, which should point to <path_where_you_want_the_venv>/simsopt_ve/bin/python.

Install simsopt

  1. If using conda, activate the conda virtual environment
    conda activate <your_conda_ve>
    Otherwise activate the virtual environment based on python3-venv
    source <path_where_you_want_the_venv>/simsopt_ve/bin/activate
    
  2. Install simsopt. It is advisable to install mpi4py.
    1. If you are using conda, first install mpi4py

      conda install -c anaconda -n <your_conda_ve> mpi4py
    2. If installing from pypi inside conda virtual environment, run

      pip install "simsopt"
      

      else to install mpi4py along with simsopt run

      pip install "simsopt[MPI]"
      
    3. For local install, get the source code either by downloading the zip file and unzip or via git. If using zip file

       wget https://github.com/hiddenSymmetries/simsopt/archive/refs/heads/master.zip
       unzip master.zip
       cd simsopt-master
    4. If you are cloning from github

      git clone [email protected]:hiddenSymmetries/simsopt.git
      cd simsopt
    5. For editable install (if you are a developer, you don't want to repeatedly reinstall simsopt after changing the source code), use the -e flag. Otherwise you can omit the -e flag.

      pip install -e .

      or

      pip install -e ".[MPI]"

Notes

  1. If you are installing simsopt at multiple environments with different compilers or different versions of libraries, use --no-cache-dir option when running the pip command.
    pip install --no-cache-dir "simsopt[MPI]"
    

Simsopt install with conda tool-chain only

The following instructions for conda work for installing vmec also.

  1. Install conda. The installation instructions can be found here. (For catalina, you can install xcode up to version 12.1 and command line tools up to v12.1 before installing conda)

  2. Add conda-forge channel.

    conda config --add channels conda-forge
  3. Create a conda virtual environment and activate it. Instructions can be found here.

  4. Install netcdf-fortran, openmpi-mpicc, openmpi-mpifort, and openblas (for VMEC2000)

    conda install netcdf-fortran openmpi-mpicc openmpi-mpifort openblas scalapack

    Also install VMEC build dependencies such as mpi4py, scikit-build, numpy, f90wrap

    conda install mpi4py scikit-build numpy f90wrap
  5. Install VMEC2000 from github.com/hiddensymmetries. Follow the instructions [here] (https://github.com/hiddensymmetries/vmec2000). Copy cmake/machines/cmake_mac_manual_conda_config.json to cmake_config_file.json. Then install VMEC2000.

  6. Build simsopt wheel. First, manually install the build dependencies.

    pip install "setuptools[scm]"

    Inside the simsopt folder, build the wheel by running

    python setup.py bdist_wheel

    Change to dist folder and install simsopt from the newly built whl file by running

    cd dist
    pip install <newly-built-file-ending-with-.whl>