Skip to content

Build your own McStas or McXtrace via conda‐forge

Peter Willendrup edited this page Dec 10, 2025 · 4 revisions

Linux / macOS

Preparation

  1. Get yourself a conda-environment, we recommend micromamba:
    "${SHELL}" <(curl -L micro.mamba.pm/install.sh)
  2. Clone the McCode repo (or your personal fork of it):
    git clone https://github.com/McCode/

Bootstrap conda development environment

  1. Use the in-repo python script to create a YaML file including build- and runtime-dependencies:
    python ./devel/bin/mccode-create-conda-yml -n mcstas-dev > mcstas-dev.yml
    (Defaults are for McStas, use --help for McXtrace settings)
  2. Create the environment:
    micromamba create -f mcstas-dev.yml
  3. Activate the environment:
    micromamba activate mcstas-dev

Build McStas

  1. Use the in-repo python script to build McStas from your current checkout:
    python ./devel/bin/mccode-build-conda
    (Defaults are for McStas, use --help for McXtrace settings)

Windows 10 and later

Preparation

  1. Get Visual Studio (e.g. the Community edition) via the Windows store
    Windows-store-get-VS
    and run the "Visual Studio Installer".
  2. Within the installer, select and install "Desktop development with C++" and select C++/CLI support, MSVC v142 - VS 2019 and later build tools for x64/x86
    MSVC-selection
  3. Enable "Developer Mode" in Windows:
    Developer-mode
  4. Start cmd.exe and get a conda system (we recommend using micromamba):
    curl -L -o micromamba.exe https://github.com/mamba-org/micromamba-releases/releases/latest/download/micromamba-win-64
  5. Set up to initialise cmd.exe for micromamba:
    micromamba.exe shell init --shell cmd.exe
    (If prompted, our recommendation is to enable long path support)
  6. Activate the base environment and install git and python:
    micromamba activate base followed by micromamba install git python

Bootstrap conda development environment

  1. Clone the McCode repo (or your personal fork of it), allowing symlink-creation in the process:
    git clone -c core.symlinks=true https://github.com/mccode-dev/McCode
  2. Change directory to the git clone cd McCode
  3. Use the in-repo python script to create a YaML file including build- and runtime-dependencies:
    python .\devel\bin\mccode-create-conda-yml -n mcstas-dev > mcstas-dev.yml
    (Defaults are for McStas, use --help for McXtrace settings)
  4. Create and activate the environment:
    micromamba create -f mcstas-dev.yml followed by micromamba activate mcstas-dev

Build McStas

  1. Use the in-repo python script to build McStas from your current checkout:
    python .\devel\bin\mccode-build-conda
    (Defaults are for McStas, use --help for McXtrace settings)

Clone this wiki locally