Fortran package manager on conda-forge

I’m more than happy to announce that the Fortran package manager is now available on conda-forge! We have versions for Linux (x86_64, aarch64 and ppc64le) and MacOS (x86_64 and aarch64) already available there.

Conda (channel only)Conda (channel only)

Go ahead and give it a try, you can grab a conda version from the mini-forge project if you don’t have a conda installation already. If not available yet, enable the conda-forge channel with:

conda config --add channels conda-forge

Once the conda-forge channel has been enabled, fpm can be installed with:

conda create -n fpm fpm
conda activate fpm

Might take another half an hour until the fpm package propagated through the CDN of conda-forge.


How does it work?
John (@urbanjost) suggested to use a single Fortran file version of fpm to bootstrap. With this approach compiling fpm on all systems and for all package managers just boils down to

$FC $LDFLAGS $FFLAGS fpm-*.f90 -o $PREFIX/bin/fpm

All the fpm releases now have a single source file version available to allow us to get started packaging.

11 Likes

I can confirm this works on WSL. :partying_face:

Very convenient! Thanks for the great work.

Click for details

(base) ip@DESKTOP-2A3E6VU:/mnt/c/Users/Ivan$ conda create -n fpm fpm
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.8.3
  latest version: 4.9.2

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /home/ipribec/miniconda3/envs/fpm

  added / updated specs:
    - fpm


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    fpm-0.1.4                  |       h1990efc_1         248 KB  conda-forge
    libgcc-ng-9.3.0            |      h2828fa1_18         7.8 MB  conda-forge
    libgfortran-ng-9.3.0       |      hff62375_18          22 KB  conda-forge
    libgfortran5-9.3.0         |      hff62375_18         2.0 MB  conda-forge
    libgomp-9.3.0              |      h2828fa1_18         376 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        10.4 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-1_gnu
  fpm                conda-forge/linux-64::fpm-0.1.4-h1990efc_1
  libgcc-ng          conda-forge/linux-64::libgcc-ng-9.3.0-h2828fa1_18
  libgfortran-ng     conda-forge/linux-64::libgfortran-ng-9.3.0-hff62375_18
  libgfortran5       conda-forge/linux-64::libgfortran5-9.3.0-hff62375_18
  libgomp            conda-forge/linux-64::libgomp-9.3.0-h2828fa1_18


Proceed ([y]/n)? y


Downloading and Extracting Packages
libgfortran-ng-9.3.0 | 22 KB     | ################################################################################################################################################### | 100%
fpm-0.1.4            | 248 KB    | ################################################################################################################################################### | 100%
libgfortran5-9.3.0   | 2.0 MB    | ################################################################################################################################################### | 100%
libgcc-ng-9.3.0      | 7.8 MB    | ################################################################################################################################################### | 100%
libgomp-9.3.0        | 376 KB    | ################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate fpm
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(fpm) ip@DESKTOP-2A3E6VU:/mnt/c/Users/Ivan$ conda activate fpm
(fpm) ip@DESKTOP-2A3E6VU:/mnt/c/Users/Ivan$ fpm -h
NAME
   fpm(1) - A Fortran package manager and build system

SYNOPSIS
   fpm SUBCOMMAND [SUBCOMMAND_OPTIONS]

   fpm --help|--version|--list

DESCRIPTION
   fpm(1) is a package manager that helps you create Fortran projects
   from source -- it automatically determines dependencies!

   Most significantly fpm(1) lets you draw upon other fpm(1) packages
   in distributed git(1) repositories as if the packages were a basic
   part of your default programming environment, as well as letting
   you share your projects with others in a similar manner.

   All output goes into the directory "build/" which can generally be
   removed and rebuilt if required. Note that if external packages are
   being used you need network connectivity to rebuild from scratch.

   ...

Output from fpm help command is cut.

1 Like

Generating quite some interest on Twitter:

4 Likes

I just enabled the support for aarch64 architecture on OSX, more commonly known as Apple Silicon. Since I cross-compiled using GFortran 11 the binary is currently untested, if you have access such a system, let me know if the native fpm binary works for you.

1 Like

I just tested it on M1 Mac and it works! I had to do conda install fpm for fpm, then fpm new works, and to get fpm run working I had to do conda install gfortran.

1 Like

gfortran supports Apple Silicon? I thought the GCC team still had a lot of work to do before that would be supported. Or is this just the x86 version running with Rosetta?

You can check the feedstock at GitHub - conda-forge/gfortran_osx-64-feedstock: A conda-smithy repository for gfortran_osx-64. for more details, which contains all the native compilers and the cross compilers targeting OSX. There is a feedstock output of GFortran for native compilation on OSX/aarch64 available.

1 Like

I think it is based on the ongoing effort by Iain Sandoe:

2 Likes

I’ll check it later today. I just installed gfortran using Conda on M1 Mac and everything just worked. I haven’t checked what kind of binary it generated, so I will do so and report back.

Ok, here is the output:

$ gfortran expr2.f90
$ file a.out        
a.out: Mach-O 64-bit executable arm64

Here is the verbose output:

$ gfortran -v expr2.f90
Driving: gfortran -v expr2.f90 --sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=11.2.0 -asm_macosx_version_min=11.2 -l gfortran
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/Users/ondrej/mambaforge/envs/gf/libexec/gcc/arm64-apple-darwin20.0.0/11.0.1/lto-wrapper
Target: arm64-apple-darwin20.0.0
Configured with: ../configure --prefix=/Users/ondrej/mambaforge/envs/gf --build=x86_64-apple-darwin13.4.0 --host=arm64-apple-darwin20.0.0 --target=arm64-apple-darwin20.0.0 --with-libiconv-prefix=/Users/ondrej/mambaforge/envs/gf --enable-languages=fortran --disable-multilib --enable-checking=release --disable-bootstrap --disable-libssp --with-gmp=/Users/ondrej/mambaforge/envs/gf --with-mpfr=/Users/ondrej/mambaforge/envs/gf --with-mpc=/Users/ondrej/mambaforge/envs/gf --with-isl=/Users/ondrej/mambaforge/envs/gf
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.1 20210313 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.2.0' '-asm_macosx_version_min=11.2' '-mlittle-endian' '-mabi=lp64' '-dumpdir' 'a-'
 /Users/ondrej/mambaforge/envs/gf/libexec/gcc/arm64-apple-darwin20.0.0/11.0.1/f951 expr2.f90 -fPIC -quiet -dumpdir a- -dumpbase expr2.f90 -dumpbase-ext .f90 -mmacosx-version-min=11.2.0 -mlittle-endian -mabi=lp64 -version -fintrinsic-modules-path /Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/finclude -o /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//ccFD9j0C.s
GNU Fortran (GCC) version 11.0.1 20210313 (experimental) (arm64-apple-darwin20.0.0)
	compiled by GNU C version Clang 11.1.0, GMP version 6.2.1, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-IMath-32

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 11.0.1 20210313 (experimental) (arm64-apple-darwin20.0.0)
	compiled by GNU C version Clang 11.1.0, GMP version 6.2.1, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-IMath-32

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.2.0'  '-mlittle-endian' '-mabi=lp64' '-dumpdir' 'a-'
 /Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/as -arch arm64 -v -mmacosx-version-min=11.2 -o /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//cclyGvZL.o /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//ccFD9j0C.s
clang version 11.1.0
Target: aarch64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Users/ondrej/mambaforge/envs/gf/bin
 "/Users/ondrej/mambaforge/envs/gf/bin/clang-11" -cc1as -triple arm64-apple-macosx11.2.0 -filetype obj -main-file-name ccFD9j0C.s -target-cpu apple-a7 -target-feature +fp-armv8 -target-feature +neon -target-feature +crypto -target-feature +zcm -target-feature +zcz -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir /Users/ondrej/repos/lfortran/lfortran/examples -dwarf-debug-producer "clang version 11.1.0" -dwarf-version=4 -mrelocation-model pic -o /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//cclyGvZL.o /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//ccFD9j0C.s
Reading specs from /Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.2.0'  '-mlittle-endian' '-mabi=lp64' '-dumpdir' 'a-'
COMPILER_PATH=/Users/ondrej/mambaforge/envs/gf/libexec/gcc/arm64-apple-darwin20.0.0/11.0.1/:/Users/ondrej/mambaforge/envs/gf/libexec/gcc/arm64-apple-darwin20.0.0/11.0.1/:/Users/ondrej/mambaforge/envs/gf/libexec/gcc/arm64-apple-darwin20.0.0/:/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/:/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/
LIBRARY_PATH=/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/:/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/../../../
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.2.0'  '-mlittle-endian' '-mabi=lp64' '-dumpdir' 'a.'
 /Users/ondrej/mambaforge/envs/gf/libexec/gcc/arm64-apple-darwin20.0.0/11.0.1/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ -dynamic -arch arm64 -macosx_version_min 11.2.0 -weak_reference_mismatches non-weak -o a.out -L/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1 -L/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/../../.. /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//cclyGvZL.o -lgfortran -lemutls_w -lgcc -lm -lemutls_w -lgcc -lSystem -lgcc -rpath /Users/ondrej/mambaforge/envs/gf/lib -no_compact_unwind -v
collect2 version 11.0.1 20210313 (experimental)
/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/ld -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ -dynamic -arch arm64 -macosx_version_min 11.2.0 -weak_reference_mismatches non-weak -o a.out -L/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1 -L/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1/../../.. /var/folders/wm/h8g03zb53_sgm6r8r8h9pmpw0000gp/T//cclyGvZL.o -lgfortran -lemutls_w -lgcc -lm -lemutls_w -lgcc -lSystem -lgcc -rpath /Users/ondrej/mambaforge/envs/gf/lib -no_compact_unwind -v
@(#)PROGRAM:ld  PROJECT:ld64-530
BUILD 14:45:47 Mar  5 2021
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
	/Users/ondrej/mambaforge/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/11.0.1
	/Users/ondrej/mambaforge/envs/gf/lib
	/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
Framework search paths:
	/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/

It seems it generates ARM executables.

2 Likes

Great!
I have just installed fpm in a Fedora 34 virtual machine, using conda (which is in Fedora repos). :grinning:
As it is the first time I use conda, this is some remarks for people like me:
after conda create -n fpm fpm I was obliged to type:

$ conda init bash

then close and re-open the terminal.
Then:

(base) [osboxes@localhost ~]$ fpm
bash: fpm: command not found...
(base) [osboxes@localhost ~]$ conda activate fpm
(fpm) [osboxes@localhost ~]$ fpm --version
Version:     0.2.0, alpha
Program:     fpm(1)
Description: A Fortran package manager and build system
Home Page:   https://github.com/fortran-lang/fpm
License:     MIT
OS Type:     Linux

As far as I understand, I must type $ conda activate fpm each time I open a terminal and need fpm, conda being also an environment manager.

Could people familiar with conda post here the very basics needed to work on an fpm project using conda?

1 Like

Yes, you create an environment conda create -n fpm fpm gfortran ... and load it conda activate fpm, after first initializing your bash or zsh. Then all the packages that you put in the environment are available.

1 Like

Thanks, so the first fpm is the name of the environment, and the second fpm is the package…

1 Like

Yes, exactly. …

1 Like

Conda is a complete and self-contained environment manager. The initialization is required once to modify your shells configuration accordingly (check your .bashrc).

Note that, there is always the possibility to install directly in the base environment with

conda install fpm

I used conda this way for a while, but I did eventually regret having bloated the base environment with too many packages, because some of them (especially compilers) can interfere with the system package manager (especially if you are packaging yourself). Fortunately, purging a conda installation is easy and one can start over again quickly.

Having now fully embraced the advantages of a separate environment manager beside my system package manager, I usually recommend to use conda by installing packages into their own environment.

2 Likes

Yes, I also recommend separate environments, I never install anything in the base environment for the reasons Sebastian wrote.

1 Like