diff --git a/python/manifests/init.pp b/python/manifests/init.pp index c933810..f572bb5 100644 --- a/python/manifests/init.pp +++ b/python/manifests/init.pp @@ -129,3 +129,67 @@ define python::compile() { } } + + +# Install pip. +# +class python::pip { + + case $::operatingsystem { + 'openbsd': { + $package = 'py-pip' + } + default: { + $package = 'python-pip' + } + } + + package { $package: + ensure => installed, + } + +} + + +# Install python package using pip. +# +# === Parameters +# +# $name: +# Package name. +# +# $source: +# Optional source path to package archive. +# +define python::pip::install($source=undef) { + + require python::pip + + if $source { + $filename = basename($name) + + file { "/usr/local/src/${filename}": + ensure => present, + mode => '0644', + owner => 'root', + group => $::operatingsystem ? { + 'openbsd' => 'wheel', + default => 'root', + }, + source => $source, + } + + exec { "pip-install-${filename}": + refreshonly => true, + path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin', + command => "pip install --no-deps --no-index --upgrade /usr/local/src/${filename}", + subscribe => File["/usr/local/src/${filename}"], + } + } else { + package { $name: + ensure => installed, + provider => 'pip', + } + } + +}