Blog post - Creating a Conda package from Fortran using fpm and rattler-build

I’ve been messing around a bit with Pixi and rattler-build* recently and thought it would be useful to write a blog post on how to use rattler-build to build a Conda package from Fortran code, using fpm as the build script.

Here is said blog post: Creating a Conda package from Fortran using fpm and rattler-build · Sam Harrison

To me, using fpm to manage the Fortran project and rattler-build to build into a Conda package is a nicely streamlined way of managing Fortran Conda packages.

I discovered a couple of other exciting things along the way:

  • The conda-forge GFortran package is now available for Windows! This is pretty huge and removes a big stumbling block in building Fortran packages on Windows. See here for a bit of context: Conda toolchain for Fortran on Windows - Fortran Discourse.
  • It seems that rattler-build uses the latest version of GFortran (14.2) when specifying ${{ compiler('fortran') }} in the build requirements (at least on Linux). This is different to conda-build (unless it’s changed recently), which uses some ancient version of GFortran on Linux and FLang on Windows.

Thoughts welcome!

*New tools to manage Conda packages, that are generally better than Conda’s own tools.

7 Likes

I’ve been using Pixi also, and I agree it is awesome (for me it fixes most issues I have with conda). It’s on my TODO list to learn rattler and how to build a package that way. Thanks for writing the blog post and sharing it here!

1 Like

Agreed, I really like Pixi! If you’re used to conda-build, then rattler-build will be easy for you. It’s not a drop-in replacement (the schemas for the recipe files are slightly different), but it’s conceptually close enough to be easy to make the switch.

1 Like

Yes, I’ve used plenty of conda-build.

One thing I am missing in Pixi are global environments like Conda has. The closest thing I found is to expose individual binaries globally using pixi global, although there are still some rough edges to polish: Simplify exposing local binaries globally · Issue #2406 · prefix-dev/pixi · GitHub.

One could use pixi shell for that, which works quite well. But being able to “activate” and “deactivate” a given pixi environment in the current shell would be better I think.

1 Like