Installing Prerequisites and the Mason Platform tools (CLI)

Beta

Please be advised that these instructions may not work for 100% of all cases. We’re working to ensure that we test our tools on various configurations in an ongoing basis. Please contact Mason Support in case you need assistance.

This page lists the software prerequisites to set up the Mason CLI (Command Line Interface”) tool (currently written in Python 2.7), used to access features of the Mason Platform.

Install via Docker

Note

We recommend using Docker for the easiest experience wherein the tool runs inside of a container regardless of the underlying OS of the development machine.

From the official Docker website:

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Steps to run the CLI via Docker

The first step is to get Docker itself installed. The Docker website has a good tutorial on the setup process which we recommend following first. Docker’s Community Edition is available here for download.

Heads up

If you have a 32-bit version of Windows or macOS, you will need to install the older “Docker Toolbox” available here.

Once that is done, you can use Mason’s official CLI Dockerfile to get the tool running.

Run the tool as shown below.

macOS or Linux

From a terminal, run:

docker run --rm -it -v $PWD:/home/masoncli masonamerica/mason-cli version

This should print out the following:

Mason Platform CLI 1.0.0
Copyright (C) 2019 Mason America (https://www.bymason.com)
License Apache 2.0 <https://www.apache.org/licenses/LICENSE-2.0>

You can alias it using your local environment’s functionality. For instance in macOS in a bash shell you can type:

alias mason='docker run --rm -it -v $PWD:/home/masoncli masonamerica/mason-cli $*'

and henceforth use mason as a shortcut to refer to the CLI command.

Windows 7 or later

Run cmd via the Start -> Run input box by typing in cmd.exe. From the cmd window, run:

docker run --rm -it -v %cd%:/home/masoncli mason-cli

Note that when running this the first time on Windows, Docker may prompt you to share the drive that the folder is located on as shown below.

Docker Windows first run prompt

You may be able to create an alias for this using the DOSKEY command from within cmd, or via a script in PowerShell or batch file (such as writing your own MASON.BAT file).

Running the Mason CLI

To run a command COMMAND, just use:

docker run --rm -it -v $PWD:/home/masoncli masonamerica/mason-cli COMMAND

or using the alias if you created one as shown above:

mason COMMAND

And you’re done!

Install via platform-specific method

To install using the platform-specific method, you will need:

  • Python 2 (version 2.7 or greater), but not Python 3.
  • The pip tool, required to install the Mason CLI
  • The git tool, a version control tool used by pip
  • The openssl security suite for APK signature verification

OS X

Python should be already pre-installed. Open Terminal from Applications, and type in python --version to confirm that it is available.

Please ensure your version of Python2 is 2.7 or greater. Python 3 is currently not supported.

Installing pip

pip is already installed if you’re using Python2 >= 2.7.9 binaries downloaded from python.org, but you’ll need to upgrade pip.

You can check if pip is installed by typing in pip --version in Terminal. If you see a message with a version number, you should be OK:

$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)

If not, you will need to install it. To do so, download this file first into the Downloads directory inside your Home directory. Then from Terminal you may install pip by typing:

python ~/Downloads/get-pip.py

See this page for more details.

git

Note that the git tool is provided via the Apple developer tools. This gets auto-installed during the installation of pip if not already detected on the system.

Installing the CLI tool

Once pip in installed, you can now install the Mason CLI from the command line like so:

  1. Open Terminal just as you did above.
  2. Type:

    python -m pip install git+https://git@github.com/MasonAmerica/mason-cli.git
    

If you see errors relating to permissions, you may need to run it instead as:

sudo python -m pip install git+https://git@github.com/MasonAmerica/mason-cli.git

Linux

The instructions for Linux are the same as for OS X. Please use a terminal anywhere there is a reference to the Terminal app, and your home directory anywhere there is a reference to the Home directory.

git should already be available on most versions of Linux. Otherwise, you may need to install it via your system’s package management software (apt or yum for example).

Please ensure your version of Python2 is 2.7 or greater. Python 3 is currently not supported.

You may visit this page for details on installing pip that are most relevant to your situation.

Windows

Note

  • For Windows users we recommend downloading cmder from https://cmder.net/ to run Mason CLI
  • The instructions below have been tested on Windows 7 and Windows 10, and should work for many cases but we’re unable to provide any additional support at this time.

Install Python

  1. Download the installer from this link.
  2. Run the downloaded installer file, and follow directions to install it into a directory, say c:\Python27.
  3. Press Windows+R and type cmd to open up the Windows command prompt.
  4. In the command prompt, type cd C:\Python27
  5. Then type python --version to confirm that it prints out the name and version of Python installed.

Install git

  1. Download git for Windows from http://git-scm.com/download/win.
  2. Run the installer that you just downloaded and follow instructions. Ensure you select all options (especially any that refer to installation or setup of git bash which adds support for Unix tools such as grep, bash and openssl).
    1. When it prompts you about Adjusting your PATH environment, pick the option Use Git from the Windows Command Prompt
    2. For the prompt Configure the line ending conversions, choose the option Checkout Windows-style, commit Unix-style line endings
    3. For the prompt Configuring the terminal emulator to use with Git Bash, choose Use Windows’ default console window
    4. This video shows how to install git for Windows correctly to ensure you get the mason CLI running.
  3. When installation is complete, you will be offered the option of opening a Git bash window (a shortcut should also be created on your desktop). Ensure this is selected in order to get a bash window where you can use git as well as many Unix-like commands, and where you have access to openssl which is required to run some of the mason subcommands.

Git bash option

Setup pip

The Windows version of Python includes pip.

Install the CLI

You can now install the Mason CLI from the command prompt like so:

  1. In a new command prompt window (just like you used in step 4 and 5 above in section Install Python, make sure you’re still in the C:\Python27 folder:

    cd /D c:\Python27
    
  2. Then type

    python -m pip install git+https://git@github.com/MasonAmerica/mason-cli.git
    

    If you are prompted for a GitHub username and password, press Esc to ignore that and press <Enter> if prompted for a password. It should now proceed to install the tool.

  3. You can run the mason command as python -m mason to ensure it has been installed. Note that there is a mason.exe that will be generated and placed in C:\Python27\Scripts. You may create a Windows batch file named mason.bat that directly invokes this executable in order to run your mason tool to avoid typing python -m mason each time.