Python-FLINT installation and notes

The python-flint package is a very fast math library. The piston in a sphere implementation outdoes the mpmath version by at least an order of magnitude.

The installation and setup is a bit more detailed, and so here are the steps.

  • Download GMP (>=6.3.0), MPFR (>=4.2.1) and FLINT (3.0.1 was used here)

  • If you are on a Windows machine, ensure you have MSYS2 MinGW or something equivalent (e.g. cygwin).

  • Unzip/tar the downloaded files and cd into them.

  • Install the packages in a explicitly specified directory, so you know where they are (this especially helps when working on an HPC cluster like that of the MPCDF) using ./configure --prefix=<absolute path here>

Install GMP

  • ./configure --prefix=<absolute path here>

  • make

  • make install

Install MPFR

  • ./configure --prefix=<absolute path here>, alternately, you may need to specify where GMP was built too with ./configure --prefix=<rest of the path>/mpfr-4.2.1 --with-gmp-include=<rest of the path>/gmp-6.3.0/include/ --with-gmp-lib=<rest of the path>/gmp-6.3.0/lib/. You may also need to pass the additional --enable-static --disable-shared arguments (at least on Windows using MSYS2 MinGW) if suggested.

  • make

  • make install

Install FLINT

  • run ./bootstrap.sh. On MSYS2 MinGW, there may be problems related to autoconf etc. All of these errors can be solved by installing the following: pacman -S base-devel, followed by pacman -S autoconf-wrapper and then pacman -S libtool automake

  • ./configure --prefix=<rest of the path>/flint --with-gmp-include=<abs path to gmp 'include' directory> --with-gmp-lib=<abs path to gmp 'lib' directory> --with-mpfr-lib=<abs path tompfr 'lib' directory> --with-mpfr-include=<abs path to mpfr 'include' directory>

  • make

  • make install

Install python-flint

  • pip install python-flint

  • Also tell python where to find the FLINT package. In Linux this is done with export LD_LIBRARY_PATH=<rest of the abs path here>/flint, and you are ready to start using python-flint. In Windows you could either export the environmental variable LD_LIBRARY_PATH using os.environ['LD_LIBRARY_PATH']=<abs path here to the flint directory>. In principle, you could also add LD_LIBRARY_PATH to your environmental variables, but I’ve not tried this yet.