PMPYTHON(1)

πŸ“¦
version 7.2.2 Β· 3 versions
, in arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– PMPYTHON(1) β€” the pmpython manual, but make it make sense πŸ’–

okay bestie, welcome to the General Commands Manual glow-up of pmpython. sit down, grab a boba, we're doing this πŸ§‹βœ¨


✨ NAME ✨

pmpython β€” run a python script using a preferred python variant πŸπŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

pmpython [python-args-and-script]

🌸 DESCRIPTION 🌸

so the whole point of pmpython, bestie, is that it gives you a way to run python scripts with a customisable python interpreter instead of hard-coding the name of one specific python version into every single script. no cap. it's giving "portable" and we are obsessed πŸ’–

this is genuinely useful because it means version-independent python code can just run anywhere. all the python modules that ship with PCP support versions 2.6 and later (in the python2 series) and 3.3 and later (in the python3 release series). periodt.

and like, because python monitoring and collecting scripts in PCP are pretty simple (they don't need new modules, new language features, none of that), it's been totally possible to make sure they work across all of the versions above. easy. iconic. 🫢

BUT β€” and here's the plot twist β€” the name of the python interpreter is not always the same everywhere 😭. so it's super common for PCP python scripts to use a "shebang" line that launches the python interpreter indirectly, like this:

#!/usr/bin/env pmpython

env(1) is the one that finds the correct path for the pmpython executable from the user's $PATH. she's the finder, she's the girl πŸ’…

by default, the name of the python interpreter is found from the value of $PCP_PYTHON_PROG from the environment (if it's set), else from /etc/pcp.conf. the second one is the more typical case, where this value is based on some heuristics about the platform at the time the PCP packages were built β€” and it favours the use of python3 in all recent releases of PCP (for those platforms that support it). slay ✨

so basically: this lets an appropriate name be used for the python interpreter instead of a hard-coded python version name, while still letting the user override the python interpreter, like so:

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

see how easy that was?? 😌 this is convenient for shipping identical scripts on multiple platforms, and for testing different python versions with the one script β€” for example, when multiple versions of python are installed, PCP_PYTHON_PROG can be set in the local environment to override the global setting. main character energy fr fr πŸ‘‘

oh and one more thing bestie: pmpython is a replacement for an earlier tool with similar function, namely pcp-python(1). we don't gatekeep, but we do upgrade 🌈


🌟 PCP ENVIRONMENT 🌟

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. and the $PCP_CONF variable may be used to specify an alternative configuration file, as described in pcp.conf(5). iykyk πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹

env(1), pcp(1), pcp-python(1) and PCPIntro(1). go read them, bestie, they're all right there πŸŽ€


and that's the whole page πŸ’– no cap, you now know pmpython better than most people know their own wifi password.

this little love letter to portability came to you from Performance Co-Pilot (that's the PCP girlies πŸ‘‘), and it's the PMPYTHON(1) page in all her glory. mwah, bye bestie πŸ«ΆπŸ’…βœ¨

πŸ“¦ where this page comes from