Class: PoisePython::Resources::PythonRuntime::Resource

Inherits:
Chef::Resource
  • Object
show all
Defined in:
lib/poise_python/resources/python_runtime.rb

Overview

A python_runtime resource to manage Python installations.

Examples:

python_runtime '2.7'

Since:

  • 1.0.0

Provides:

  • python_runtime

Actions:

  • install

  • uninstall

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pip_versionString, Boolean

Note:

Due to https://github.com/pypa/pip/issues/1087, the latest version of pip will always be installed initially. It will then downgrade to the requested version if needed.

Note:

Disabling the pip install may result in other resources being non-functional.

Version of pip to install. If set to true, the latest available pip will be used. If set to false, pip will not be installed. If set to a URL, that will be used as the URL to get-pip.py. If a non-URL version is given, the get-pip.py installer will be downloaded from the internet.

Examples:

Install from a locally-hosted copy of get-pip.py

python_runtime '2' do
  pip_version 'http://myserver/get-pip.py'
end

Returns:

  • (String, Boolean)


65
# File 'lib/poise_python/resources/python_runtime.rb', line 65

attribute(:pip_version, kind_of: [String, TrueClass, FalseClass], default: true)

#setuptools_versionString, Boolean

Version of Setuptools to install. It set to true, the latest available version will be used. If set to false, setuptools will not be installed.

Returns:

  • (String, Boolean)


71
# File 'lib/poise_python/resources/python_runtime.rb', line 71

attribute(:setuptools_version, kind_of: [String, TrueClass, FalseClass], default: true)

#versionString

Version of Python to install. The version is prefix-matched so '2' will install the most recent Python 2.x, and so on.

Examples:

Install any version

python_runtime 'any' do
  version ''
end

Install Python 2.7

python_runtime '2.7'

Returns:

  • (String)


48
# File 'lib/poise_python/resources/python_runtime.rb', line 48

attribute(:version, kind_of: String, name_attribute: true)

#virtualenv_versionString, Boolean

Note:

Disabling the virtualenv install may result in other resources being non-functional.

Version of Virtualenv to install. It set to true, the latest available version will be used. If set to false, virtualenv will not be installed. Virtualenv will never be installed if the built-in venv module is available.

Returns:

  • (String, Boolean)


80
# File 'lib/poise_python/resources/python_runtime.rb', line 80

attribute(:virtualenv_version, kind_of: [String, TrueClass, FalseClass], default: true)

#wheel_versionString, Boolean

Version of Wheel to install. It set to true, the latest available version will be used. If set to false, wheel will not be installed.

Returns:

  • (String, Boolean)


86
# File 'lib/poise_python/resources/python_runtime.rb', line 86

attribute(:wheel_version, kind_of: [String, TrueClass, FalseClass], default: true)

Instance Method Details

#python_binaryString

The path to the python binary for this Python installation. This is an output property.

Examples:

execute "#{resources('python_runtime[2.7]').python_binary} myapp.py"

Returns:

  • (String)

Since:

  • 1.0.0



94
95
96
# File 'lib/poise_python/resources/python_runtime.rb', line 94

def python_binary
  provider_for_action(:python_binary).python_binary
end

#python_environmentHash<String, String>

The environment variables for this Python installation. This is an output property.

Examples:

execute '/opt/myapp.py' do
  environment resources('python_runtime[2.7]').python_environment
end

Returns:

  • (Hash<String, String>)

Since:

  • 1.0.0



106
107
108
# File 'lib/poise_python/resources/python_runtime.rb', line 106

def python_environment
  provider_for_action(:python_environment).python_environment
end