Note: If you don’t use Visual Studio (e.g., on other C/C++ projects), a simpler (and preferred) method for setting up Landlab can be found at Landlab developer install on Windows (with gcc).
Building Landlab from source on Windows is trickier than on Linux or macOS. Below are some steps, based on recent experience, that should work.
Install Visual Studio
Landlab has many parts that are written in C, and we need a C compiler to build them. Download Visual Studio Community Edition and install it. We don’t need to use Visual Studio directly, but the compiler and linker included with it are used in the Landlab build process.
During installation, be sure to select this option:
- “Desktop development with C++” workload
This is what will install the compiler and linker with Visual Studio.
Install Miniforge
To set up a Python environment to run Landlab, we use Miniforge. Download the Windows installer for Miniforge and run it.
During installation, be sure to select these three options:
- “Create shortcuts”
- “Add Miniforge3 to my PATH environment variable” (even though a warning is given against this)
- “Register Miniforge as my default Python”
We’ll use the Miniforge Prompt, which is installed in the Windows Start menu, for the next steps.
Create a conda environment
Through the Miniforge prompt, use conda to create a virtual environment for the Landlab developer install.
conda create -y -n landlab_dev python pip compilers git
Note that we’re including the conda compilers (which map to Visual Studio) in this environment, as well as git, pip, and python, all of which we’ll use below.
Activate the new environment.
conda activate landlab_dev
A host of status messages will stream past. The messages should end with text like this:
[vcvarsall.bat] Environment initialized for: 'x64'
Clone the Landlab repository
From the Miniforge prompt, use git to clone the Landlab repository to your computer.
git clone git@github.com:landlab/landlab.git
You may wish to fork Landlab and clone your fork instead. You’ll need an SSH key pair set up on your computer for communicating with GitHub. See this lesson from CSDMS Ivy for more information.
The cloned repository lives in a directory called landlab. Change to this directory.
cd landlab
Install Landlab into the conda environment
From the Miniforge prompt, in the landlab directory with the activated landlab_dev environment, build Landlab from source and install it with pip.
pip install -e ".[dev,testing]"
Check that Landlab is installed by starting a Python session from the Miniforge prompt.
python
In the Python session, import the landlab package and check its version.
>>> import landlab
>>> landlab.__version__
'2.10.2.dev0'
That’s it!