Merged in osalmi/puppet/feature-python-pip (pull request #66)
Add support for installing packages with pip, fix lint warnings
This commit is contained in:
commit
f9b2b7bca3
1 changed files with 140 additions and 66 deletions
|
@ -2,21 +2,21 @@
|
|||
#
|
||||
class python {
|
||||
|
||||
package { "python":
|
||||
ensure => installed,
|
||||
notify => $::operatingsystem ? {
|
||||
"openbsd" => Exec["python-links"],
|
||||
default => undef,
|
||||
},
|
||||
}
|
||||
package { 'python':
|
||||
ensure => installed,
|
||||
notify => $::operatingsystem ? {
|
||||
'openbsd' => Exec['python-links'],
|
||||
default => undef,
|
||||
},
|
||||
}
|
||||
|
||||
exec { "python-links":
|
||||
path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin",
|
||||
command => "pkg_info python | egrep '^[ ]*ln -sf' | sh",
|
||||
user => "root",
|
||||
group => "wheel",
|
||||
refreshonly => true,
|
||||
}
|
||||
exec { 'python-links':
|
||||
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin',
|
||||
command => 'pkg_info python | egrep "^[ ]*ln -sf" | sh',
|
||||
user => 'root',
|
||||
group => 'wheel',
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ class python {
|
|||
#
|
||||
class python::python26 {
|
||||
|
||||
if $::operatingsystem in ["CentOS","RedHat"] and versioncmp($::operatingsystemrelease, "6") < 0 {
|
||||
package { "python26":
|
||||
ensure => installed,
|
||||
}
|
||||
if $::operatingsystem in ['CentOS','RedHat'] and versioncmp($::operatingsystemrelease, '6') < 0 {
|
||||
package { 'python26':
|
||||
ensure => installed,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,21 @@ class python::python26 {
|
|||
#
|
||||
class python::m2crypto {
|
||||
|
||||
package { "m2crypto":
|
||||
ensure => installed,
|
||||
name => $::operatingsystem ? {
|
||||
"debian" => "python-m2crypto",
|
||||
"ubuntu" => "python-m2crypto",
|
||||
default => "m2crypto",
|
||||
}
|
||||
case $::operatingsystem {
|
||||
'debian','ubuntu': {
|
||||
$package = 'python-m2crypto'
|
||||
}
|
||||
'openbsd': {
|
||||
$package = 'py-M2Crypto'
|
||||
}
|
||||
default: {
|
||||
$package = 'm2crypto'
|
||||
}
|
||||
}
|
||||
|
||||
package { $package:
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,51 +61,51 @@ class python::m2crypto {
|
|||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Source directory.
|
||||
# $python:
|
||||
# Python executable name. Defaults to python.
|
||||
# $source:
|
||||
# Source path to package archive.
|
||||
# $name:
|
||||
# Source directory.
|
||||
# $python:
|
||||
# Python executable name. Defaults to python.
|
||||
# $source:
|
||||
# Source path to package archive.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# python::setup::install { "/usr/local/src/moin-1.8.8":
|
||||
# source => "puppet:///files/packages/moin-1.8.8.tar.gz",
|
||||
# python::setup::install { '/usr/local/src/moin-1.8.8':
|
||||
# source => 'puppet:///files/packages/moin-1.8.8.tar.gz',
|
||||
# }
|
||||
#
|
||||
define python::setup::install(
|
||||
$python="python",
|
||||
$source=undef,
|
||||
$python='python',
|
||||
$source=undef,
|
||||
) {
|
||||
|
||||
if $source {
|
||||
$filename = basename($source)
|
||||
file { "/usr/local/src/${filename}":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
source => $source,
|
||||
}
|
||||
util::extract::tar { $name:
|
||||
ensure => latest,
|
||||
strip => "1",
|
||||
source => "/usr/local/src/${filename}",
|
||||
require => File["/usr/local/src/${filename}"],
|
||||
before => Exec["python-setup-install-${name}"],
|
||||
}
|
||||
if $source {
|
||||
$filename = basename($source)
|
||||
file { "/usr/local/src/${filename}":
|
||||
ensure => present,
|
||||
mode => '0644',
|
||||
owner => 'root',
|
||||
group => $::operatingsystem ? {
|
||||
'openbsd' => 'wheel',
|
||||
default => 'root',
|
||||
},
|
||||
source => $source,
|
||||
}
|
||||
util::extract::tar { $name:
|
||||
ensure => latest,
|
||||
strip => '1',
|
||||
source => "/usr/local/src/${filename}",
|
||||
require => File["/usr/local/src/${filename}"],
|
||||
before => Exec["python-setup-install-${name}"],
|
||||
}
|
||||
}
|
||||
|
||||
exec { "python-setup-install-${name}":
|
||||
path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin",
|
||||
cwd => $name,
|
||||
command => "/bin/sh -c 'umask 022; ${python} setup.py install && mkdir -p build'",
|
||||
creates => "${name}/build",
|
||||
}
|
||||
exec { "python-setup-install-${name}":
|
||||
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin',
|
||||
cwd => $name,
|
||||
command => "/bin/sh -c 'umask 022; ${python} setup.py install && mkdir -p build'",
|
||||
creates => "${name}/build",
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,8 +114,8 @@ define python::setup::install(
|
|||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# File name to compile.
|
||||
# $name:
|
||||
# File name to compile.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
|
@ -116,9 +123,76 @@ define python::setup::install(
|
|||
#
|
||||
define python::compile() {
|
||||
|
||||
exec { "python -c \"import py_compile; py_compile.compile('${name}')\"":
|
||||
path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin",
|
||||
onlyif => "test '${name}' -nt '${name}c'",
|
||||
}
|
||||
exec { "python -c \"import py_compile; py_compile.compile('${name}')\"":
|
||||
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin',
|
||||
onlyif => "test '${name}' -nt '${name}c'",
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# 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,
|
||||
}
|
||||
|
||||
# Use exec to install from local files, pip package provider does not
|
||||
# support extra arguments. --no-index stops pip from accessing
|
||||
# pypi.
|
||||
exec { "pip-install-${filename}":
|
||||
refreshonly => true,
|
||||
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin',
|
||||
command => "pip install --no-index --upgrade /usr/local/src/${filename}",
|
||||
subscribe => File["/usr/local/src/${filename}"],
|
||||
}
|
||||
} else {
|
||||
package { $name:
|
||||
ensure => installed,
|
||||
provider => 'pip',
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue