Installing fpm

This how-to guide covers the installation of the Fortran Package Manager (fpm) on various platforms.

Download binaries

Binaries for macOS, Linux, and Windows (all on x86-64) are available for download for each release of fpm, as well as the latest (bleeding edge) release which mirrors the latest commit in the main branch of fpm.

Navigate to fpm releases to see all available releases. The downloadable files are available at the bottom of each release section under Assets. Click on the appropriate link based on your OS. For example, to download a macOS fpm binary, click on the link that has macos in its name. After downloading, you will need to make your binary executable. On Linux and macOS, you can do this by typing

chmod +x fpm-0.5.0-linux-x86_64

Optionally, place the binary in a directory that is globally accessible (i.e. in the PATH environment variable on Linux and macOS). You can also rename the binary to just fpm for easier use.

For Windows, both a self-contained binary and a Windows Installer for fpm are available.

Примечание

Links that end with .sha256 provide the cryptographic hashes that you can use to verify if the download of your binary was successful. To verify the integrity of the downloaded binary the checksum can be computed locally and compared with the one provided in the release

❯ openssl sha256 -r fpm-0.5.0-linux-x86_64
387782f29b19eb6fbf14dd5cef76907a4c9cb6d20726d5508a78225ccd131ca8 *fpm-0.5.0-linux-x86_64
❯ cat fpm-0.5.0-linux-x86_64.sha256
387782f29b19eb6fbf14dd5cef76907a4c9cb6d20726d5508a78225ccd131ca8  fpm-0.5.0-linux-x86_64

If the checksums mismatch, the download was most likely incomplete and the binary non-functional. In this case, retry the download of the binary and confirm that the checksums match.

MSYS2 package manager

MSYS2 mingw package

The MSYS2 project provides a package manager and makes many common Unix tools available for Windows.

Примечание

To install download the msys2-x86_64-YYYYMMDD.exe installer from the MSYS2 webpage and run it. MSYS2 will create several new desktop shortcuts, like MSYS terminal, MinGW64 terminal and UCRT64 terminal (more information on MSYS2 terminals are available here).

The Fortran Package Manager is supported for the UCRT64, MinGW64, or MinGW32 terminal.

Open a new terminal and update your installation with

pacman -Syu

You might have to update MSYS2 and pacman first, restart the terminal and run the above command again to update the installed packages.

If you are using the MinGW64 terminal you can install the required software with

pacman -S git mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-fpm

Совет

Both git and gfortran are not mandatory dependencies for running fpm. If you provide git and gfortran from outside they will get picked up as well.

Homebrew package manager

The Fortran Package Manager (fpm) is available for the homebrew package manager on MacOS via an additional tap. To install fpm via brew, include the new tap and install it using

brew tap fortran-lang/homebrew-fortran
brew install fpm

Binary distributions are available for MacOS 11 (Catalina) and 12 (Big Sur) for x86_64 architectures. For other platforms fpm will be built locally from source automatically.

Fpm should be available and functional after those steps.

Macports

MacPorts package

The Fortran Package Manager (fpm) is available via macports and can be installed with

sudo port install fpm

Fpm should be available and functional after those steps.

Conda package manager

Conda (channel only)

Fpm is available on conda-forge, to add conda-forge to your channels use:

conda config --add channels conda-forge

Fpm can be installed with:

conda create -n fpm fpm
conda activate fpm

Alternatively, if you want fpm to be always available directly install into your current environment with

conda install fpm

Примечание

The conda package manager can be installed from miniforge or from miniconda.

Spack package manager

Spack package

Fpm is available with spack in its develop version. To install fpm from spack use

spack install fpm

You can add +openmp to enable parallelization of the target compilation in fpm. To use fpm in your environment load it with

spack load fpm

For more details check the package information here.

Arch Linux user repository

AUR version AUR version

The Arch Linux user repository (AUR) contains two packages for the Fortran Package Manager (fpm). With the fortran-fpm-bin installs the statically linked Linux/x86_64 binary from the release page, while the fortran-fpm package will bootstrap fpm from source.

Select one of the PKGBUILDs and retrieve it with

git clone https://aur.archlinux.org/fortran-fpm.git
cd fortran-fpm

As usual, first inspect the PKGBUILD before building it. After verifying the PKGBUILD is fine, build the package with

makepkg -si

Once the build passed pacman will ask to install the fpm package.

OpenBSD ports

OpenBSD port

A port for OpenBSD is available in the default port tree. To install fpm install the devel/fpm port with

cd /usr/ports/devel/fpm
make install clean

WinGet

winget package

The installer provided from the fpm release can be used via WinGet to install fpm:

winget install FortranLang.fpm

Building from source

To build fpm from source get the latest fpm source, either by cloning the repository from GitHub with

git clone https://github.com/fortran-lang/fpm
cd fpm

or by downloading a source tarball from the latest source

wget https://github.com/fortran-lang/fpm/archive/refs/heads/main.zip
unzip main.zip
cd fpm-main

The available install script allows to bootstrap fpm by using just a Fortran compiler, git and network access. Invoke the script to start the bootstrap build

./install.sh

Fpm will be installed in ~/.local/bin/fpm.

Примечание

Building the bootstrapper binary from the single source file version might take a few seconds, which might make the install script look like it is hanging.

Совет

The installation location can be adjusted by passing the --prefix=/path/to/install option.

If you can’t run the install script, you can perform the bootstrap procedure manually, with the following three steps:

  1. Download the single source version of fpm

    wget https://github.com/fortran-lang/fpm/releases/download/current/fpm.F90
    
  2. Build a bootstrap binary from the single source version

    mkdir -p build/bootstrap
    gfortran -J build/bootstrap -o build/bootstrap/fpm fpm.F90
    
  3. Use the bootstrap binary to build the feature complete fpm version

    ./build/bootstrap/fpm install