macOS

Homebrew

To install CLI tools and libraries on macOS while retaining basic sanity, it is strongly recommended to use the Homebrew package manager. If you have not already installed it, it can be done like this:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This will also prompt you to install the “Xcode command line tools” if you have not done so already. You will need those to build any software, including Rust software, so that’s a good thing.

CLI tools and libraries

Now that the basics are covered, we can install all needed packages as follows:

brew install curl hdf5 hwloc pkgconf unzip util-linux wget

You may get a warning stating that pkgconf can’t be installed because pkg-config is installed. This is harmless: they are two compatible implementations of the same functionality.

Rust

To compile Rust code, you will need a Rust toolchain. You can install the one we need like this:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none  \
&& . "$HOME/.cargo/env"  \
&& rustup toolchain install nightly-2024-10-28

If you want to use rust-analyzer, you may want to add a --component rust-analyzer flag to the rustup toolchain install command at the end. This will ensure that you get a rust-analyzer version that is fully compatible with the compiler version that we are going to use.

HDF5-to-PNG renderer

Throughout the second part of the course, we will be producing HDF5 files which contain time series of tabulated chemical concentrations. For quick and dirty debugging, it is convenient to render those tabulated concentrations into colorful PNG images.

To this end, you can use the data-to-pics program which was developed as part of a previous version of this course. It can be installed as follows:

cargo install --git https://github.com/HadrienG2/grayscott.git data-to-pics

Environment test

Your Rust development environment should now be ready for this course’s practical work. I highly advise testing it by using the following shell script:

wget https://plmlab.math.cnrs.fr/grasland/numerical-rust-cpu/-/archive/solution/numerical-rust-cpu-solution.zip  \
&& unzip numerical-rust-cpu-solution.zip  \
&& rm numerical-rust-cpu-solution.zip  \
&& cd numerical-rust-cpu-solution/exercises  \
&& cargo run -- -n3  \
&& mkdir pics  \
&& data-to-pics -o pics/  \
&& cd ../..  \
&& rm -rf numerical-rust-cpu-solution

It downloads, builds and runs the expected source code at the end of the last chapter of this course, then renders the associated images, and finally cleans up after itself by deleting everything.