Installation

McStasScript needs to be installed and then configured. There are two ways to install, either through pip or from the source code directly. The configuration can be done after installation and changed at any point.

Before installing McStasScript, install McStas or McXtrace as described on www.mcstas.org or www.mcxtrace.org.

Pip

The standard way to install McStasScript is through pip. For Unix and OS X, use this line in the terminal. For windows, use the McStas-shell or McXtrace-shell to run the install.

pip install McStasScript --upgrade

From source

A developer might one to install directly from source, this makes it easier to contribute to the project and see how changes to the code affect the package.

Open a terminal and go to the location where the source code should be located, and use these commands.

git clone https://github.com/PaNOSC-ViNYL/McStasScript.git
cd McStasScript
pip install -r requirements.txt
pip install -e .

Configuration

The McStasScript package has a configuration file in the source directory that can be changed with a text editor or through a configurator class included in the package. The configuration needs the path of the mcrun / mxrun executable and the base directory of the McStas/McXtrace installation.

Typical Mac OS configuration

import mcstasscript as ms
my_configurator = ms.Configurator()
my_configurator.set_mcrun_path("/Applications/McStas-2.7.1.app/Contents/Resources/mcstas/2.7.1/bin/")
my_configurator.set_mcstas_path("/Applications/McStas-2.7.1.app/Contents/Resources/mcstas/2.7.1/")
my_configurator.set_mxrun_path("/Applications/McXtrace-1.5.app/Contents/Resources/mcxtrace/1.5/bin/")
my_configurator.set_mcxtrace_path("/Applications/McXtrace-1.5.app/Contents/Resources/mcxtrace/1.5/")
print(my_configurator)

Typical Unix configuration

import mcstasscript as ms
my_configurator = ms.Configurator()
my_configurator.set_mcrun_path("/usr/bin/")
my_configurator.set_mcstas_path("/usr/share/mcstas/2.7.1/")
my_configurator.set_mxrun_path("/usr/bin/")
my_configurator.set_mcxtrace_path("/usr/share/mcxtrace/1.5/")
print(my_configurator)

Typical Windows configuration

import mcstasscript as ms
my_configurator = ms.Configurator()
my_configurator.set_mcrun_path("\\mcstas-2.7.1\\bin\\")
my_configurator.set_mcstas_path("\\mcstas-2.7.1\\lib\\")
my_configurator.set_mxrun_path("\\mcxtrace-1.5\\bin\\")
my_configurator.set_mcxtrace_path("\\mcxtrace-1.5\\lib\\")    
print(my_configurator)

Tests

In order to ensure the installation and configuration was successful, one can run the test suite. Navigate to the folder containing the McStasScript source code and run:

pytest

If pytest has not been installed yet, it can be installed with

pip install pytest