Skip to content

Get NCrystal

Thomas Kittelmann edited this page Jul 31, 2023 · 14 revisions

There are various manners in which one might acquire NCrystal. We mention a few on this page. No matter how you get it, proceed to the After installation, you are ready to Using-NCrystal page afterwards.

1. Install via conda

NCrystal is available in the conda-forge channel, for instance via the command:

conda -c conda-forge ncrystal

This should give you a fully-functional NCrystal release.

2. Install via pip

NCrystal is also available on PyPI, so it can be installed via the command:

python3 -mpip install ncrystal

Again, this should give you a fully-functional NCrystal release. The one exception is that the NCrystal CMake files are not automatically found by downstream CMake-based projects. To make it work, one must add the path returned by the command ncrystal-config --show cmakedir to the CMAKE_PREFIX_PATH environment variable, or alternatively embed this logic inside the downstream CMake files. This can for instance, be done by replacing a simple find_package(NCrystal REQUIRED) statement with the following slightly more elaborate code which cause CMake to query the ncrystal-config command for the appropriate NCrystal_DIR setting:

execute_process( COMMAND ncrystal-config --show cmakedir
                 OUTPUT_VARIABLE NCrystal_DIR
                 OUTPUT_STRIP_TRAILING_WHITESPACE )
find_package(NCrystal REQUIRED)

2. Install from source

2.1 Getting the source

First step in installing NCrystal is to download the source distribution. Most users should simply download the latest release from this page as a tar-ball or zip-file which must then be unpacked. It is of course also possible to simply clone the github repository. We are always very careful to ensure that the HEAD of the master branch is always containing the lastest recommended release.

2.2 Building the source and installing

Please refer to the instructions in the INSTALL file which comes with the source distribution. Note that most users will need CMake installed (v3.10 or later), a C/C++ compiler with C++11 support, and Python (v3.6+ or later) in order to proceed.

3. Get it along with some other software.

Some users will get NCrystal available along with their other software. Most notably, the McStas releases on non-Windows platform often include an NCrystal installation in the $MCSTAS directory. To enable it, source the setup.sh script found therein (note: it might be eventually by moved to a different folder or renamed to ncrystal-setup.sh or something similar). Once you have found it, sourced it by typing e.g. . $MCSTAS/share/NCrystal/setup.sh in a terminal.