State Tool

Introducing the State Tool

Wouldn’t it be great if any developer could run a single command and immediately get started contributing code to your project? And wouldn’t it be even better to automate all of the tedious configuration workflow you usually go through? This is exactly what ActiveState is working to facilitate with our State Tool.

With the first release of the State Tool we’re focusing on one of the most important components: setting up your Python runtime environment on Linux.

This means that once you have set up your runtime environment, by creating a Project on the ActiveState Platform and are getting successful builds you can instantly deploy your runtime environment locally using the State Tool. The State Tool creates a virtual environment, similar to virtualenv and pipenv, and will not contaminate any of the preexisting Python installations or environments you have configured.

Important: This is a preview release of the State Tool which includes features that we are actively developing and it will include frequent changes. We may release updates that are not backwards compatible and require you to make configuration or workflow changes. It is not yet ready for production use.

Installation

Note: Currently, the State Tool is supported for ActivePython and ActivePerl projects on Linux and Windows. Upcoming releases will support macOS and additional languages.

Important: This is a preview release of the State Tool which includes features that are under active development and it will include frequent changes. We may release updates that are not backwards compatible and require you to make configuration or workflow changes. It is not yet ready for production use.

Installation on Linux

You should have curl installed before you can run the script to install the State Tool. Alternatively, you can manually download and run the install.sh file.

  1. Open your command prompt and enter the following command on one line:

    sh <(curl -q https://platform.activestate.com/dl/cli/install.sh)
    

    The latest version of the State Tool will be downloaded, verified, and installed.

Installation on Windows

  1. Start your command prompt (cmd.exe) as an Adminstrator. Click the Start menu, search for Command Prompt, right click it and select Run as Administrator.
  2. At the prompt, enter the following command:

    powershell "IEX(New-Object Net.WebClient).downloadString('https://platform.activestate.com/dl/cli/install.ps1')"
    

    The latest version of the State Tool will be downloaded, verified, and installed.

Usage

The basic usage for setting up a local virtual environment with your project is:

$ state activate owner/projectName

Where “owner” refers to your username or the organization name that the project belongs to.

Working with your activated project

There are two ways to reactivate an existing project:

  • Enter state activate owner/projectName anywhere on your system and you will be given the option to reuse your previously used directory and enter into an activated state.
  • Open your terminal and navigate to the directory that contains the activestate.yaml file for the project and enter state activate without any additional arguments.

To verify that your environment is “activated”:

  • When in an activated state the “ACTIVESTATE_ACTIVATED” environment variable will be defined. Also if your terminal shell allows for it an informational message starting with Active State: will be printed after each command is executed. On Linux, you can check the value of the environment variable by entering the following command:

    printenv | grep ACTIVESTATE_ACTIVATED
    

Using Your Project

Whenever you’re in an “activated state” your shell will be configured to use the runtime environment you created on the ActiveState Platform. Any preexisting Python installations you have will be overridden ONLY while using the “activated state”.

Sharing With Your Team

Now that you have your activestate.yaml configuration file set up you can share it with your team. You can do this however you prefer, but if your team is using version control we recommend checking in your activestate.yaml file. As we add new capabilities you can update your configuration in the activestate.yaml file and share these capabilities with your team.

Command Reference

This release of the State Tool includes four commands for interacting with the ActiveState Platform and your projects.