Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.
/ puppet-pyenv Public archive

Commit

Permalink
Merge branch 'master' into 0.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Sluijters committed Apr 30, 2014
2 parents b6267d2 + d6552b5 commit 40826d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 54 deletions.
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Pythons outside of your platforms package manager's purview.
3. [Setup - The basics of getting started with pyenv](#setup)
* [Beginning with pyenv - Installation](#beginning-with-pyenv)
* [Installing a Python - Basic options for getting started](#installing-a-python)
* [Resource ordering](#resource-ordering)
* [Relocating pyenv](#relocating-the-pyenv-installation)
4. [Usage - The classes and types available for configuration](#usage)
* [Classes](#classes)
Expand Down Expand Up @@ -75,31 +74,6 @@ the Python:
pyenv_python { '3.4.0-debug': }
```

### Resource ordering
Unfortunately due to how Puppet works there is no way to instruct the provider
that in order for it to work it needs to wait on the *vcsrepo* resource and only
then evaluate possible candidates.

Because of this we provide a fact called `pyenv_installed` which will try to
detect if pyenv is installed. The fact takes into account the value of the
`pyenv_binary` fact, searches through `$PATH` and tries to find pyenv at
`/usr/local/pyenv/bin/pyenv`. If any of those succeed the value will be `true`,
else it will return `false`.

This means you can now do:

```puppet
if str2bool($::pyenv_installed) {
pyenv_python { '3.4.0': }
}
```

Using this trick means that you will need two Puppet runs the first time:

* The first to setup pyenv, at this point `pyenv_installed` will be `false`;
* The second run will now detect that pyenv is installed, `pyenv_installed`
will be `true` and the Pythons will be built.

### Relocation the pyenv installation
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
Expand Down
28 changes: 0 additions & 28 deletions lib/facter/pyenv_installed.rb

This file was deleted.

9 changes: 9 additions & 0 deletions lib/puppet/feature/pyenv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'puppet/util/feature'

Puppet.features.add(:pyenv) {
if not Facter.value('pyenv_binary').nil?
File.executable?(Facter.value('pyenv_binary'))
else
File.executable?('/usr/local/bin/pyenv')
end
}
1 change: 1 addition & 0 deletions lib/puppet/provider/pyenv_python/pyenv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Puppet::Type.type(:pyenv_python).provide(:pyenv) do

defaultfor :feature => :posix
confine :feature => :pyenv

if not Facter.value(:pyenv_binary).nil?
has_command(:pyenv, Facter.value(:pyenv_binary)) do
Expand Down

0 comments on commit 40826d5

Please sign in to comment.