Easiest route: build with pixi
If you use pixi, the repo now has a pixi.toml workspace that provides the
entire toolchain and all build dependencies from conda-forge and drives the
full build:
pixi run build # C code + libpresto + Python package, installed into the pixi env
pixi run test # quick smoke tests
pixi shell # drop into the environment (prepfold, python, etc. on PATH)
Use pixi run install-py-editable after building if you want live-editable
pure-Python modules while debugging. The pixi tasks use their own meson build
directory (build-pixi/), so they will not interfere with a manually managed
build/. Notes: ERFA is built automatically (it is not on conda-forge), and
tempo2 (used for polyco generation) is included from conda-forge — no TEMPO
installation is needed at all.
With v5, we have switched to building and installing with meson.
MacOS users should see the comments at the bottom of this file!
If you are interested in using Docker or Singularity containers of PRESTO, see the bottom of this file!
As always, there are a set of essential packages required to build PRESTO. This command should do it on a Debian/Ubuntu-like system:
apt install git build-essential libfftw3-bin libfftw3-dev libgsl28 libgsl-dev liberfa-dev pgplot5 libglib2.0-dev libcfitsio-bin libcfitsio-dev libpng-dev ghostscript gfortran tcsh autoconf libx11-dev python3-dev python3-numpy python3-pip
Setting the PRESTO environment variable is now optional — the installed tools locate their runtime data (the pulsar catalog, etc.) automatically in {prefix}/share/presto. It is still handy as a shorthand for the commands below (which use $PRESTO) and works as an override when running from an uninstalled source tree, so you may want to point it at the top-level PRESTO git checkout. Either way, make sure that $PRESTO/lib and $PRESTO/bin are not in your PATH or LD_LIBRARY_PATH or PYTHONPATH environment variables as we have required in the past. It is probably a good idea to clean your earlier compiles, as well.
From your activated Python virtual or Conda environment, make sure that you have meson, meson-python, ninja, and a recent pip installed (also Python >=3.8):
pip install meson meson-python ninja or conda install meson meson-python ninja
and
pip install --upgrade pip.
Now setup the C/Fortran code builds:
cd $PRESTO
meson setup build --prefix=$CONDA_PREFIX if you use Conda/Mamba/Anaconda
or
meson setup build --prefix=$VIRTUAL_ENV if you use a Python virtual environment
or
meson setup build --prefix=$HOME if you want things installed in your $HOME/bin, $HOME/lib directories.
or, if you have sudo permissions and want to install to /usr/local (or equivalent system directory):
meson setup build.
Note that if you don't want to set --prefix on the command line, you can also edit the top-level meson.build file and add e.g. 'prefix=/home/sransom' to the default_options variable in the project definition.
In order to avoid the possible issues with linking and running, I recommend doing:
python check_meson_build.py.
If all looks good, it will let you know. If not, I recommend trying to fix the issues that it caught, and then starting again.
Now do the actual build and install via:
meson compile -C build
meson install -C build
You will see a lot of compiler warnings due to my crappy C-coding (I should fix those...), but that's OK. There should be logs in case anything goes wrong in $PRESTO/build/meson-logs. You should be able to run prepfold (for example), at this time and see the usage information. If that doesn't work, see the troubleshooting information below.
Then finally, install the Python codes and bindings via pip:
cd $PRESTO/python
pip install .
And that should do it! You can quickly test to see if most things are working by doing:
cd $PRESTO
python tests/test_presto_python.py
python examplescripts/ffdot_example.py
python python/fftfit_src/test_fftfit.py
Another good test is to see if you can run and fit the default profile in pygaussfit.py
If you want slightly faster FFT calls, just run the installed makewisdom. By default it uses FFTW_MEASURE and skips the largest FFT sizes, so it finishes in a few seconds; add -patient to instead use FFTW_PATIENT over the full set of sizes for higher-quality (but much slower, ~10-20 min) wisdom. It writes fftw_wisdom.txt straight into {prefix}/share/presto (or $PRESTO/lib if you have PRESTO set), which is where PRESTO looks for it at runtime — no manual copying needed. You can pass an explicit output path as an argument to override the destination.
Note that you can uninstall everything via:
cd $PRESTO/build
ninja uninstall
pip uninstall presto
Some quick troubleshooting info for the new meson build process:
- If you get an error when trying to run one of the compiled executables (like
prepfold) about shared libraries (e.g.prepfold: error while loading shared libraries: libpresto.so: cannot open shared object file: No such file or directory) you will need to add the install location oflibpresto.soto yourLD_LIBRARY_PATHenvironment variable.- Note: You can find the install location by doing:
grep libpresto $PRESTO/build/meson-logs/install-log.txt
- Note: You can find the install location by doing:
- If you get an error when running
pip install ...for the Python codes saying../meson.build:29:15: ERROR: C shared or static library 'presto' not found, you will need to do something similar to the above and add the install location oflibpresto.sotoLIBRARY_PATH(note that that is notLD_LIBRARY_PATH! The former is for runtime linking and the latter is for linking at compile time. Note that you might need to useDYLD_LIBRARY_PATHon macOS!)
(Note: For MacOS users, please see the bottom of the document!)
-
Install FFTW3
I highly recommend that you use pre-compiled packages for your OS/distribution! For example, Ubuntu has good FFTW packages:
libfftw3-binandlibfftw3-dev.If you compile your own, you need to compile FFTW for single precision. For all architectures I recommend the following configuration:
./configure --enable-shared --enable-singleIf you are on a modern Intel processor and have a recent version of GCC, you can get much improved performance by adding:
--enable-sse --enable-sse2 --enable-avx --enable-avx2 --enable-fma -
Install PGPLOT
I highly recommend that you use pre-compiled packages for your OS/distribution! For example, Ubuntu has a good PGPLOT package:
pgplot5. You will likely need to set thePGPLOT_DIRenvironment variable. On Ubuntu, I havePGPLOT_DIR=/usr/lib/pgplot5If you want to try to compile your own (good luck!), you need the X-windows and postscript drivers at a minimum.
-
Install tempo2 (only needed for polycos)
tempo2 is used for polyco generation (e.g.
prepfold -timing); if you don't fold with polycos you can skip it. The easiest install is from conda-forge (conda/pixi install tempo2), which also sets the requiredTEMPO2runtime environment variable automatically (note: there is no conda-forge build for osx-arm64). If you build from source instead, setTEMPO2to the runtime directory yourself.Note: as of the post-v5.3.1 development code, TEMPO is no longer used at all — barycentering is done in-process via ERFA, and polycos come from tempo2.
-
Install ERFA (optional -- can be automatic!)
ERFA does the barycentering-related astronomical calculations. If it is not already installed, meson will automatically download and build it as a subproject (via
subprojects/erfa.wrap), so you can skip this step if your build machine has network access. To use a system copy instead: on Ubuntu the packages areliberfa1andliberfa-dev. Note that thepyerfaPython package (conda-forge/PyPI/astropy) does not provide the C library and headers that PRESTO needs. For a fully offline build without a system ERFA, download the release tarball and place it insubprojects/packagecache/(keeping the original filename) before runningmeson setup. -
Install GLIBv2
On Linux machines this is almost certainly already on your system (check in
/usr/liband/usr/include/glib*). Although you may need to install a glib development package in order to have the required include files. On Ubuntu, the package you need is:libglib2.0-dev -
Install GSL
I highly recommend that you use pre-compiled packages for your OS/distribution! For example, Ubuntu has good GSL packages:
libgsl28andlibgsl-dev. -
Install CFITSIO
I highly recommend using pre-compiled packages, once again (on Ubuntu they are
libcfitsio-binandlibcfitsio-dev), however, this is a very easy install via source. -
(Optional) Set the
PRESTOenvironment variableThis is no longer required — the installed tools find their runtime data in
{prefix}/share/prestoon their own. SettingPRESTOto the top level directory of the PRESTO distribution (i.e. this directory) is still useful as a shorthand for the commands below and as an override for running from an uninstalled source tree. Whether or not you set it, make sure that$PRESTO/liband$PRESTO/binare not in yourPATHorLD_LIBRARY_PATHorPYTHONPATHenvironment variables as we have required in the past. -
Activate your Python virtual environment or Conda/Mamba/Anaconda environment
- That environment should have
numpyinstalled at a minimum - Make sure that
pipis recent (pip install --upgrade pip) - Install the build tools:
pip install meson meson-python ninjaorconda install meson meson-python ninja
- That environment should have
-
Configure the meson build
In the top level PRESTO directory (i.e. `cd $PRESTO`), configure `meson` via:
`meson setup build --prefix=$CONDA_PREFIX` if you use Conda/Mamba/Anaconda
or
`meson setup build --prefix=$VIRTUAL_ENV` if you use a Python virtual environment
or
`meson setup build --prefix=$HOME` if you want things installed in your `$HOME/bin`, `$HOME/lib` directories.
or, if you have sudo permissions and want to install to `/usr/local` (or equivalent):
`meson setup build`.
-
Check your environment variables against the configuration
python check_meson_build.pyIf everything looks good, it will tell you. Otherwise, try fixing the issues and starting over from step #8.
-
Build and install all the C/Fortran codes and the PRESTO shared library (e.g.
libpresto.so)meson compile -C buildmeson install -C buildThere should be logs in case anything goes wrong in
$PRESTO/build/meson-logs. Note that all PRESTO compiled binaries will be installed in{prefix}/{bindir}, and the PRESTO shared library (likely eitherlibpresto.soorlibpreso.dylib) will be installed in{prefix}/{libdir}as defined bymeson. You can see the values of{prefix},{bindir}, and{libdir}using thecheck_meson_build.pyscript from the previous step. -
Try running a PRESTO command like
prepfoldYou should get the regular usage screen. If you get a shared library error, see the troubleshooting steps above or below.
-
Compile and install the PRESTO python codes and libraries
cd $PRESTO/pythonpip install .If you get a shared library error, see the troubleshooting steps above or below.
-
Run some basic tests
cd $PRESTOpython tests/test_presto_python.pypython examplescripts/ffdot_example.pypython python/fftfit_src/test_fftfit.pyAnother good test is to see if you can run and fit the default profile in
pygaussfit.py -
Run
makewisdomto have (slightly) fast FFTsJust run
makewisdom(it is installed to{prefix}/bin). By default it usesFFTW_MEASUREand skips the largest FFT sizes, so it only takes a few seconds. For higher-quality wisdom over the full set of sizes, runmakewisdom -patient, which usesFFTW_PATIENTand takes about 10-20 min, so be patient. Either way it writesfftw_wisdom.txtdirectly into{prefix}/share/presto(or$PRESTO/libif you havePRESTOset), which is where PRESTO looks for it at runtime, so no manual move is needed. To write it elsewhere, pass an output path as an argument. -
Go find pulsars!
Everything should be ready to go now, and installed (likely) in the same place as the rest of your Python virtual environment and/or Conda/Mamba/Anaconda environment.
If you want to uninstall everything you can do:
cd $PRESTO/buildninja uninstallpip uninstall presto
Scott Ransom Updated Oct 2025, for v5.2.0
Couple quick trouble-shooting tips if you are having problems compiling and running:
-
Environment variables! Use
python check_meson_build.py!- Is
PRESTOset to the top-level PRESTO source directory? - Is
TEMPO2set to the tempo2 runtime directory (only needed for polycos; automatic with conda-forge's tempo2)? - Is
PGPLOT_DIRset to the location of the PGPLOT utility files? (Note: On Ubuntu, that should be/usr/lib/pgplot5) - Is
$PRESTO/binin yourPATH? (It should not be!) - Is
$PRESTO/libin yourLD_LIBRARY_PATH? (It should not be!) - Is there any
prestostuff in yourPYTHONPATH? (There should not be!)
- Is
-
Have you have installed the relevant
-devpackages forglib2,FFTW,GSL, andCFITSIOif you are using a Debian-based Linux distribution? Here are the required packages on a clean Ubuntu:gitbuild-essentiallibfftw3-binlibfftw3-devlibgsl28libgsl-devpgplot5libglib2.0-devlibcfitsio-binlibcfitsio-devlibpng-devghostscriptgfortrantcshautoconflibx11-devpython3-devpython3-numpypython3-pip
And the following command should get all of them:
apt install git build-essential libfftw3-bin libfftw3-dev libgsl28 libgsl-dev liberfa-dev pgplot5 libglib2.0-dev libcfitsio-bin libcfitsio-dev libpng-dev ghostscript gfortran tcsh autoconf libx11-dev python3-dev python3-numpy python3-pip -
After the Python modules are built and installed, and you run
python tests/test_presto_python.py, if you get a memory error, please contact Scott! I think that these issues are fixed, but if they are not, we will need to change the build process a tiny bit with a special variable define. -
If you are having trouble with PRESTO creating polycos, you can use
prepfoldwith the-debugoption when folding using-timing. That will show you thetempo2call and keep all of the (usually) temporary output files. -
If the python build or install is failing, it can be useful to save and inspect the build directory via
pip install --config-settings=builddir=build ..
If you are using MacOS, Paul Ray has been running PRESTO a lot and knows several tricks to get it working:
-
PRESTO should build almost "out of the box" on a Mac, once you have the external packages installed and after setting a few environment variables.
-
For MacPorts, which has worked well, this should install all the important packages. This assumes you use Python 3.11 and gcc13. You may use different versions.:
% sudo port install mp-gcc13 python311 py311-ipython pip311 virtualenv311 virtualenvwrapper311 % sudo port select --set gcc mp-gcc13 % sudo port select --set python python311 % sudo port select --set virtualenv virtualenv311 % sudo port select --set virtualenvwrapper virtualenvwrapper311 % sudo port install pgplot cfitsio gsl glib2 fftw-3 fftw-3-single -
tempo2 (only needed for polycos) is available from conda-forge for osx-64; on osx-arm64 you currently need to build it from source.
-
Before you build, you will likely need to set the following environment variables. You probably do not need to have
DYLD_LIBRARY_PATHset at runtime.# These are needed only at *BUILD* time # This points to the MacPorts libraries and those installed in your virtualenv, # as well as a manually installed PGPLOT (not needed if PGPLOT is installed by MacPorts) export LIBRARY_PATH=/opt/local/lib:/opt/local/lib/libgcc:$VIRTUAL_ENV/lib:$PGPLOT_DIR # This prevents using the macOS native "cc" command, in favor of the MacPorts gcc export CC=gcc # This makes sure the MacPorts includes can be found export CFLAGS="-I/opt/local/include -I$PGPLOT_DIR" -
If you are using Homebrew instead, Alessandro Ridolfi has successfully installed PRESTO using that, as well. Please let Alessandro or I know if you are having issues and we can send you some help.
Alessandro Ridolfi wrote recipes to create Docker images which you can use and modify in the examplescripts directory.
He made two versions: one with PNG image support (i.e. providing gs via the ghostscript package, which prepfold uses to make the nice anti-aliased .png versions of the .pfd.ps files) and the other one without the PNG support. Note that prepfold calls gs only if it is present; if it is missing, the .ps plot is still written and no error is reported. (Earlier versions of PRESTO used pstoimg from the large latex2html package for this; pstoimg was itself only a wrapper around Ghostscript, which is not available on conda-forge, so PRESTO now calls gs directly.) The files are:
- examplescripts/Dockerfile_presto5_png_ubuntu24.04.txt
- examplescripts/Dockerfile_presto5_ubuntu24.04.txt
He has also made available pre-built Docker and Singularity images which can be grabbed from his DockerHub with the following commands:
-
Docker images:
docker pull alex88ridolfi/presto5:latest docker pull alex88ridolfi/presto5:png -
Apptainer / Singularity images:
singularity pull docker://alex88ridolfi/presto5:latest singularity pull docker://alex88ridolfi/presto5:png
These can be used with commands like:
singularity shell -B /path/to/mount:/path/to/mount presto5_latest.sif
singularity shell -B /path/to/mount:/path/to/mount presto5_png.sif
These images could be of help for people who don’t want / cannot install PRESTO by themselves, or for use on HPC systems.
Alessandro is also planning to make images that include PRESTO5+PULSAR_MINER, and PRESTO5+PRESTO_GPU+PULSAR_MINER in the near future.