2. Building and Installing the AMPS Client

Obtaining the Client

The AMPS Python client is available as a download from the 60East Technologies web site, www.crankuptheamps.com. Download the client from the site, then extract it.

The client source files are in the directory where you unpacked the files. By default, this is amps-python-client-<version>, where <version> is the current version of the python client, such as amps-python-client-4.3.1.0).

Installing the Prebuilt .egg on Linux

60East provides a prebuilt .egg file for x64 Linux distributions using Python 2.7. To install the .egg:

  • To successfully install the file, you will need permission to update the Python distribution on the system you are installing on.
  • Open a command prompt
  • Run the following command, substituting the version number that you want to install for the <version_number> placeholder:
$ easy_install http://devnull.crankuptheamps.com/releases/amps/clients/amps_python_client-<version_number>-py2.7-linux-x86_64.egg

If this command reports a permission error, you do not have permission to update the Python distribution. Run the command as a different user, or use sudo to run the command as root.

Installing the Prebuilt .egg on Windows

60East provides a prebuilt .egg file for 64-bit Windows operating systems using Python 2.7. Your Python distribution may include a more fully-featured package manager to assist with installing .egg files.

To install the .egg using the command line:

  • To successfully install the file, you will need permission to update the Python distribution on the system you are installing on.
  • Make sure that your Python distribution includes setuptools.
  • Open a command prompt.
  • Make sure that the directory that contains easy_install.exe from setuptools is is in your PATH. For example, if your distribution installs the setuptools scripts into C:\Python27\Scripts, you might set your PATH as follows:
set PATH=%PATH%;C:\Python27\Scripts
  • Run the following command, substituting the version number that you want to install for the <version_number> placeholder:
$ easy_install.exe \
http://devnull.crankuptheamps.com/releases/amps/clients/amps_python_client-<version_number>-py2.7-win-amd64.egg

If this command reports a permission error, you do not have permission to update the Python distribution. Run the command prompt from a different user, or start the command prompt with Run as Administrator.

Building the Client

The main AMPS Python client distribution includes the full source to the client. For most installations, you build the client with your Python distribution before using it. The process for building the client differs slightly depending on whether you are building the client for Linux or for Windows.

Building for Linux

Follow these steps to build the Linux version of the client:

  1. The Python client includes all necessary C++ client sources. If you are using a different version of the C++ client than the one included with the Python client, set the AMPS_CPP_DIR environment variable to the location of the AMPS C++ client source.

  2. Run python setup.py build from the AMPS Python Client directory to build the client.

    This script uses the Python distutils to build the library, which makes it easy to build the library correctly and install the library into your Python distribution. To see the options available in your environment, run python setup.py --help.

    caution The module must be built with the same C++ compiler used to build python on your system. The setup.py script and distutils package will generally ensure this unless you have added a different compiler to your PATH. If you typically use a different C++ compiler, remove the path to that compiler before running setup.py.
  3. The script builds the module to a path in the build directory. The exact path depends on the version of Python you are building with.

  4. Add the build directory path to the PYTHONPATH environment variable. For example:

    $ export PYTHONPATH=/home/AMPSdev/amps-python-client/build/lib.linux-x86_64-2.7:$PYTHONPATH

  5. Test that the module loads correctly:

    $ python -c "import AMPS"

  6. Optionally, install the module to your local python installation. While this is not required, doing this makes the AMPS module available for all of the programs that use this installation of python:

    sudo python setup.py install

Building for Windows

Follow these steps to build the Windows version of the client:

  1. Use the Visual Studio Command Prompt shortcut to start a command prompt window for the type of module you want to build. For example, to build a 32-bit module, you use the command prompt for x86 builds.

  2. Add the Python directory (the location of the python.exe interpreter) to your PATH.

    tip The platform of the python installation must match the target platform for the python module. If you want to build a 64-bit module, your PATH must include a 64-bit python installation. If you want to build a 32-bit module, your PATH must include a 32-bit python installation. The build process uses whatever python.exe is found first when searching the PATH. So, to build both 32-bit and 64-bit versions, you must build them separately, and change your PATH between builds.
  3. Run python setup.py build from the AMPS Python Client directory to build the client.

    This script uses the Python distutils to build the library, which makes it easy to build the library correctly and install the library into your Python distribution. To see the options available in your environment, run python setup.py --help.

  4. The script builds the module to a path in the build directory. The exact path depends on the version of Python you are building with.

  5. Add the build directory path to the PYTHONPATH environment variable. For example:

    > set PYTHONPATH="C:\Users\AMPSdev\amps-python-client\build\lib.linux-x86_64-2.7;%PYTHONPATH%"

  6. Test that the module loads correctly:

    > python -c "import AMPS"

  7. Optionally, install the module to your local python installation.While this is not required, doing this makes the AMPS module available for all of the programs that use this installation of python:

    > python setup.py install