Pyenv provides a way to build and use Pythons outside of your platforms package manager's purview.
- Overview - What is the pyenv module?
- Module description - What is the purpose of this mdoule?
- Setup - The basics of getting started with pyenv
- Usage - The classes and types available for configuration
The pyenv module allows you to install pyenv on a target system. The module
also provides a Puppet type called pyenv_python
which will instruct pyenv
to build a Python for you.
This module only supports global installations of pyenv, meaning it will not install into a user's home directory. Though it can be made to do so the types that come with it do not support this work flow.
Python is a often-used programming language ranging from simple scripts to automate a repetitive task to powering large (web) applications. The problem we often encounter is that a distribution only ships with one (outdated) Python version. Pyenv remedies this situation by allow you to build your own Pythons and use those instead.
This modules will:
- Install pyenv for you. It will do so by checking out the latest tag at the time this module was written;
- Symlink pyenv so that it will be found when looking through
$PATH
; - Install the necessary packages to ensure you can build Python;
- A type and provider to make Puppet build Pythons through pyenv.
This module requires:
In order to install pyenv with the defaults:
include ::pyenv
This will install pyenv for you in /usr/local/pyenv
and symlink
/usr/local/bin/pyenv
to /usr/local/pyenv/bin/pyenv
.
Use the pyenv_python
type to instruct Puppet to build a Python:
pyenv_python { '3.4.0': }
The pyenv_python
defaults to ensure => present,
, therefor you do not need to
specify it yourself.
If you want to build a debug version of a Python add -debug to the name of the Python:
pyenv_python { '3.4.0-debug': }
The module installs pyenv to /usr/local/pyenv
by default and symlinks the
pyenv
binary onto your path. This is needed so that the provider can find
pyenv
and set up the PYENV_ROOT
environment variable accordingly.
If you change the location of the pyenv checkout you must either:
- Make sure the symlink is changed too. This is done automatically if you
set
symlink_pyenv
to true; - Create a custom Fact called
pyenv_binary
with the location of/path/to/checkout/bin/pyenv
.
The former of the two methods is preferred if at all possible.
If Puppet's $PATH
does not by default include /usr/local/bin
either add
that to it or change the symlink_path
to a different location that is part of
Puppet's $PATH
.
The pyenv module's primary and only class, pyenv
sets up your system with pyenv
and the necessary packages to compile.
It takes the following parameters:
ensure_repo
: Whether to add or remove the repository- default:
present
- options:
present
,absent
- default:
repo_location
: Where to checkout the repository on the filesystem- default:
/usr/local/pyenv
- options: any absolute path
- default:
repo_revision
: The revision to checkout- default:
v0.4.0-20140404
- options: tag, commit SHA, branch
- default:
symlink_pyenv
: Create a symlink to the pyenv binary- default:
true
- options:
true
,false
- default:
symlink_path
: Where to symlink pyenv to- default:
/usr/local/bin
- options: any absolute path known to
$PATH
- default:
manage_packages
: Install packages needed to compile Python- default:
true
- options:
true
,false
- default:
ensure_packages
: State of the packages to ensure- default:
latest
- options: any valid value for the ensure attribute of the package type
- default:
python_build_packages
: Array/list of packages to install- default: depends on what Facter returns for
osfamily
, see (params.pp)[params.pp] - options: an array of strings representing package names
- default: depends on what Facter returns for
pyenv_python
allows you to build a Python which in turn will make it
available to someone wishing to use it.
It takes the following options:
name
(namevar): name of the Python to be installed, seepyenv install -l
. If omitted the title of the resource will be used.ensure
: state the Python should be in- default:
present
- options: valid values for ensure
- default:
keep
: keep the sources after compiling- default:
false
- options:
true
,false
- default:
virtualenv
: Install virtualenv in the new Python- default:
false
- options:
true
,false
- default:
Keep one thing in mind: if a Python was installed without setting keep
to
true
you cannot add it later, the provider will call the fail()
method in
such cases.