Initialization scripts for the MESA SDK
Shell Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

MESA Init Scripts

These scripts simplify the management of environment variables related to MESA and the MESA SDK. They should be particularly useful for users who run multiple MESA versions or use non-SDK compilers as part of other work.

These scripts are designed to work with the bash shell. They also assume you have python3 installed.

Installation and Setup

Clone this git repository

git clone

Create a file named .mesa_init in your home directory. List the paths to your various MESA versions using ini format, as below.

    MESA_DIR = /path/to/mesa

    MESA_DIR = /path/to/mesa-r5118

    MESA_DIR = /path/to/mesa-r6794

    MESA_DIR = /path/to/mesa-r7184

You can use whatever names in the square braces that you desire. That will be your shorthand to refer to that particular version. Instead of version numbers, you might want to use descriptors associated with the particular project you are doing with that version.

Now, add the following lines to your .bashrc.

# set the MESA and MESA SDK paths
export MESA_DIR=/path/to/mesa
export MESASDK_ROOT=/path/to/mesasdk

# source the mesa init script
source /path/to/mesa-init/

# add a command to activate the SDK
activatemesasdk () {
    source /path/to/mesa-init/

# if you want, you can call it now.  I call it manually,
# since I only want the SDK active sometimes

# activatemesasdk

# __mesa_ps1 shows the MESA and MESA SDK status.
# you can use it in your bash prompt.  my PS1 looks like

# PS1='$(__mesa_ps1)\h: \W$ '

Usage with MESA

There is now a function chmesadir defined in your environment, which allows you to switch between the MESA versions you listed in .mesa_init. The function provides completion information, so you can hit tab to see or complete your options.


When you invoke it, it will change the MESA_DIR environment variable and update the variables controlling the MESA-related information displayed in your prompt.


Usage with MESA SDK

If you followed the above instructions, you defined an activatemesasdk function. Issuing this command will add the SDK to your system paths.

When you activate the SDK, it defines a deactivatemesasdk command function. Issuing this command will remove the SDK from your system paths.