Installation in Python
For basic install, follow the quick guide at Getting Started. Here we provide a more detailed installation guide for Python.
Below are the dependencies for the package:
- C compiler, preferably GCC or Clang
- CMake
- Python version >= 3.9
Optional dependencies:
- HDF5 (For data storage. Optional but recommended)
- FFTW3 (Only required for cosmological simulations)
- OpenMP
Python packages: (Check requirements.txt for the latest version)
- NumPy
- Matplotlib
- h5py
There are multiple ways to install the package, depending on your use case.
If you want to compile the package locally, you could run
// Choose the options you want
export CMAKE_ARGS="-DUSE_HDF5=ON -DUSE_OPENMP=ON -DUSE_FFTW3=ON -DCMAKE_C_COMPILER=gcc .."
pip install grav_sim --no-binary grav_sim --no-cache-dir
- -DUSE_OPENMP=ON -DUSE_FFTW3=ON -DUSE_HDF5=ON: optional flags for the dependencies.
- -DCMAKE_C_COMPILER=gcc: optional flag to specify the C compiler.
To check whether it is successfully installed, run
where--path=c_lib_path is optional argument to specify the path
to the compiled C library. You should see the compilation information and the path to the
compiled library.
-----------------------------------------------------------------
                                              __                   
    __   _ __    __     __  __           ____/\_\    ___ ___       
  /'_ `\/\`'__\/'__`\  /\ \/\ \         /',__\/\ \ /' __` __`\     
 /\ \L\ \ \ \//\ \L\.\_\ \ \_/ |       /\__, `\ \ \/\ \/\ \/\ \    
 \ \____ \ \_\\ \__/.\_\\ \___/        \/\____/\ \_\ \_\ \_\ \_\   
  \/___L\ \/_/ \/__/\/_/ \/__/   _______\/___/  \/_/\/_/\/_/\/_/   
    /\____/                     /\______\                          
    \_/__/                      \/______/                          
grav_sim version 0.0.4
Operating System: MacOS
Compilation Info:
Compiled with OpenMP: true
Compiled with HDF5: true
    Version: 1.14.6
Compiled with FFTW3: false
Build time: Apr 16 2025 13:12:32
Compiler: GCC (version: 14)
-----------------------------------------------------------------
C library location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/libgrav_sim.dylib
This way should work on all platforms as long as you could get the C library compiled on your system.
- Clone the repository to your local machine and navigate to the directory:
- Create a build directory inside the repository:
- 
Compile the library with CMake - -DUSE_OPENMP=ON -DUSE_FFTW3=ON -DUSE_HDF5=ON: optional flags for the dependencies.
- -DCMAKE_C_COMPILER=gcc: optional flag to specify the C compiler.
 
- 
Check the compilation. You should see one of the following files in the This is the compiled C library. You will need to keep track of the path to this file.builddirectory.
- 
Now you can install the Python wrapper either from PyPI or from source. - To install from PyPI, run
- To install from source, navigate to the parent directory and run
 
- 
To check whether it is successfully installed, run where--path=/path/to/compiled/c_libis the path to the compiled C library. You should see the compilation information and the path to the compiled library.
-----------------------------------------------------------------
                                            __                   
  __   _ __    __     __  __           ____/\_\    ___ ___       
/'_ `\/\`'__\/'__`\  /\ \/\ \         /',__\/\ \ /' __` __`\     
/\ \L\ \ \ \//\ \L\.\_\ \ \_/ |       /\__, `\ \ \/\ \/\ \/\ \    
\ \____ \ \_\\ \__/.\_\\ \___/        \/\____/\ \_\ \_\ \_\ \_\   
  \/___L\ \/_/ \/__/\/_/ \/__/   _______\/___/  \/_/\/_/\/_/\/_/   
    /\____/                     /\______\                          
    \_/__/                      \/______/                          
grav_sim version 0.0.5
Operating System: MacOS
Compilation Info:
  Compiled with OpenMP: false
  Compiled with HDF5: false
  Compiled with FFTW3: false
Build time: Apr 28 2025 17:06:18
Compiler: Clang (version: 15)
-----------------------------------------------------------------
C library location: /Users/alvinng/Desktop/cuhk/gravity-simulator/Final Project/grav_sim/build/lib.macosx-10.9-universal2-cpython-311/libgrav_sim.dylib