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.
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.
(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.
...
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.
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.
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?
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.
Great!
I have just installed fpm in a Fedora 34 virtual machine, using conda (which is in Fedora repos).
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?
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.
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.