Showing with 115 additions and 40 deletions.
  1. +14 −0 CHANGELOG.md
  2. +25 −0 README.md
  3. +25 −20 manifests/pip.pp
  4. +21 −16 manifests/requirements.pp
  5. +10 −4 metadata.json
  6. +20 −0 spec/defines/pip_spec.rb
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v2.1.0](https://github.com/voxpupuli/puppet-python/tree/v2.1.0) (2018-07-09)

[Full Changelog](https://github.com/voxpupuli/puppet-python/compare/v2.0.0...v2.1.0)

**Implemented enhancements:**

- support for providing pip3 provider w/ tests. Modified readme 4 examples [\#414](https://github.com/voxpupuli/puppet-python/pull/414) ([danquack](https://github.com/danquack))

**Closed issues:**

- How to deploy pip package to rhscl python34 [\#377](https://github.com/voxpupuli/puppet-python/issues/377)
- CentOS 7 with Python3 does not work [\#303](https://github.com/voxpupuli/puppet-python/issues/303)

## [v2.0.0](https://github.com/voxpupuli/puppet-python/tree/v2.0.0) (2018-06-25)

[Full Changelog](https://github.com/voxpupuli/puppet-python/compare/1.19.0...v2.0.0)
Expand All @@ -20,6 +33,7 @@ These should not affect the functionality of the module.

**Implemented enhancements:**

- Add Debian 9 Support [\#398](https://github.com/voxpupuli/puppet-python/issues/398)
- Add support for Anaconda [\#409](https://github.com/voxpupuli/puppet-python/pull/409) ([grsakea](https://github.com/grsakea))
- Add umask parameter to pip execs [\#368](https://github.com/voxpupuli/puppet-python/pull/368) ([jstaph](https://github.com/jstaph))

Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Installs and manages python, python-pip, python-dev, python-virtualenv and Gunic

**use_epel** - Boolean to determine if the epel class is used. Default: true on RHEL like systems, false otherwise

*Install Python from system python*
```puppet
class { 'python' :
version => 'system',
Expand All @@ -66,6 +67,15 @@ Installs and manages python, python-pip, python-dev, python-virtualenv and Gunic
gunicorn => 'absent',
}
```
*Install Python 3 from the scl repo*
```puppet
class { 'python' :
ensure => 'present',
version => 'rh-python36-python',
dev => 'present',
virtualenv => 'present',
}
```

### python::pip

Expand All @@ -77,6 +87,8 @@ Installs and manages packages from pip.

**virtualenv** - virtualenv to run pip in. Default: system (no virtualenv)

**pip_provider** - pip provider to execute pip with. Default: pip.

**url** - URL to install from. Default: none

**owner** - The owner of the virtualenv to ensure that packages are installed with the correct permissions (must be specified). Default: root
Expand All @@ -94,6 +106,8 @@ Installs and manages packages from pip.
**uninstall_args** - String of additional flags to pass to pip during uninstall. Default: none

**timeout** - Timeout for the pip install command. Defaults to 1800.

*Install cx_Oracle with pip*
```puppet
python::pip { 'cx_Oracle' :
pkgname => 'cx_Oracle',
Expand All @@ -106,6 +120,17 @@ Installs and manages packages from pip.
timeout => 1800,
}
```
*Install Requests with pip3*
```puppet
python::pip { 'requests' :
ensure => 'present',
pkgname => 'requests',
pip_provider => 'pip3',
virtualenv => '/var/www/project1',
owner => 'root',
timeout => 1800
}
```

### python::requirements

Expand Down
45 changes: 25 additions & 20 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# [*virtualenv*]
# virtualenv to run pip in.
#
# [*pip_provider*]
# version of pip you wish to use. Default: pip
#
# [*url*]
# URL to install from. Default: none
#
Expand Down Expand Up @@ -66,26 +69,28 @@
#
# Sergey Stankevich
# Fotis Gimian
# Daniel Quackenbush
#
define python::pip (
$pkgname = $name,
$ensure = present,
$virtualenv = 'system',
$url = false,
$owner = 'root',
$group = 'root',
$umask = undef,
$index = false,
$proxy = false,
$egg = false,
$editable = false,
$environment = [],
$extras = [],
$install_args = '',
$uninstall_args = '',
$timeout = 1800,
$log_dir = '/tmp',
$path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
$pkgname = $name,
$ensure = present,
$virtualenv = 'system',
Enum['pip', 'pip3'] $pip_provider = 'pip',
$url = false,
$owner = 'root',
$group = 'root',
$umask = undef,
$index = false,
$proxy = false,
$egg = false,
$editable = false,
$environment = [],
$extras = [],
$install_args = '',
$uninstall_args = '',
$timeout = 1800,
$log_dir = '/tmp',
$path = ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
) {
$python_provider = getparam(Class['python'], 'provider')
$python_version = getparam(Class['python'], 'version')
Expand Down Expand Up @@ -125,8 +130,8 @@
}

$pip_env = $virtualenv ? {
'system' => "${exec_prefix}pip",
default => "${exec_prefix}${virtualenv}/bin/pip",
'system' => "${exec_prefix}${pip_provider}",
default => "${exec_prefix}${virtualenv}/bin/${pip_provider}",
}

$pypi_index = $index ? {
Expand Down
37 changes: 21 additions & 16 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# [*virtualenv*]
# virtualenv to run pip in. Default: system-wide
#
# [*pip_provider*]
# version of pip you wish to use. Default: pip
#
# [*owner*]
# The owner of the virtualenv being manipulated. Default: root
#
Expand Down Expand Up @@ -62,22 +65,24 @@
# Sergey Stankevich
# Ashley Penney
# Fotis Gimian
# Daniel Quackenbush
#
define python::requirements (
$requirements = $name,
$virtualenv = 'system',
$owner = 'root',
$group = 'root',
$proxy = false,
$src = false,
$environment = [],
$forceupdate = false,
$cwd = undef,
$extra_pip_args = '',
$manage_requirements = true,
$fix_requirements_owner = true,
$log_dir = '/tmp',
$timeout = 1800,
$requirements = $name,
$virtualenv = 'system',
Enum['pip', 'pip3'] $pip_provider = 'pip',
$owner = 'root',
$group = 'root',
$proxy = false,
$src = false,
$environment = [],
$forceupdate = false,
$cwd = undef,
$extra_pip_args = '',
$manage_requirements = true,
$fix_requirements_owner = true,
$log_dir = '/tmp',
$timeout = 1800,
) {

include ::python
Expand All @@ -100,8 +105,8 @@
}

$pip_env = $virtualenv ? {
'system' => "${::python::exec_prefix} pip",
default => "${::python::exec_prefix} ${virtualenv}/bin/pip",
'system' => "${::python::exec_prefix} ${pip_provider}",
default => "${::python::exec_prefix} ${virtualenv}/bin/${pip_provider}",
}

$proxy_flag = $proxy ? {
Expand Down
14 changes: 10 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "puppet-python",
"version": "2.0.0",
"author": "stankevich",
"version": "2.1.0",
"author": "Vox Pupuli",
"summary": "Python Module",
"license": "Apache-2.0",
"source": "git://github.com/voxpupuli/puppet-python.git",
Expand Down Expand Up @@ -53,7 +53,13 @@
}
],
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0 < 6.0.0"},
{"name":"stahnma/epel","version_requirement":">= 1.2.2 < 2.0.0"}
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.6.0 < 6.0.0"
},
{
"name": "stahnma/epel",
"version_requirement": ">= 1.2.2 < 2.0.0"
}
]
}
20 changes: 20 additions & 0 deletions spec/defines/pip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@
end
end

describe 'pip_provide as' do
context 'defaults to pip' do
let(:params) { {} }

it { is_expected.to contain_exec('pip_install_rpyc').with_command(%r{pip}) }
it { is_expected.not_to contain_exec('pip_install_rpyc').with_command(%r{pip3}) }
end
context 'use pip instead of pip3 when specified' do
let(:params) { { pip_provider: 'pip' } }

it { is_expected.to contain_exec('pip_install_rpyc').with_command(%r{pip}) }
it { is_expected.not_to contain_exec('pip_install_rpyc').with_command(%r{pip3}) }
end
context 'use pip3 instead of pip when specified' do
let(:params) { { pip_provider: 'pip3' } }

it { is_expected.to contain_exec('pip_install_rpyc').with_command(%r{pip3}) }
end
end

describe 'proxy as' do
context 'defaults to empty' do
let(:params) { {} }
Expand Down