Scroll to navigation

PMPYTHON(1) General Commands Manual PMPYTHON(1)

NAME

pmpython - run a python script using a preferred python variant

SYNOPSIS

pmpython [python-args-and-script]

DESCRIPTION

pmpythonprovides a way to run python scripts using a customisable pythoninterpreter, rather than embedding the name ofa particular version of python into each script.

This can be useful as it allows version-independent python code to berun anywhere.All python modules shipped with PCP support versions 2.6 and later (inthe python2 series), and 3.3 and later (in the python3 release series).

Due to python monitoring and collecting scripts being relatively simplein PCP (not requiring new modules, language features, etc), it has beenpossible to ensure they work for all of the above python versions.

However, the name of the python interpreter is not always the same,thus,it is common for PCP python scripts to use a “shebang” line thatlaunches thepythoninterpreter indirectlyas follows:


#!/usr/bin/env pmpython

env(1)is used to find the correct path for thepmpythonexecutable from the user's$PATH.

By default the name of the python interpreter is found from thethe value of$PCP_PYTHON_PROGfrom the environment (if set) elsefrom/etc/pcp.conf.The latter is themore typical case wherethis value is based onsome heuristics about the platform at the time the PCP packages werebuild andfavour the use ofpython3in all recent releases of PCP (for those platforms that support it).

This allows an appropriate name to be used for the pythoninterpreter instead of a hard-codedpython version name, while still allowing the user to override the pythoninterpreter as follows:


$ PCP_PYTHON_PROG=python3 pmpython --version
Python 3.4.2
$ PCP_PYTHON_PROG=python2 pmpython --version
Python 2.7.9

This is convenient for shipping identical scripts on multiple platforms,and for testing different python versions with the one script (e.g. inthe case where multiple versions of python are installed, PCP_PYTHON_PROGcan be set in the local environment to override the global setting).

pmpythonis a replacement for an earlier tool with similar function, namelypcp-python(1).

PCPENVIRONMENT

Environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. On each installation, the file /etc/pcp.conf contains the local values for these variables. The $PCP_CONF variable may be used to specify an alternative configuration file, as described in pcp.conf(5).

SEEALSO

env(1),pcp(1),pcp-python(1)andPCPIntro(1).

PCP Performance Co-Pilot