You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installs and configures Python. Also includes LWRPs for managing python packages with `pip` and `virtualenv` isolated Python environments.
5
4
6
-
Requirements
7
-
============
8
-
9
-
Platform
10
-
--------
11
-
12
-
* Debian, Ubuntu
13
-
* CentOS, Red Hat, Fedora
14
5
15
-
Cookbooks
16
-
---------
6
+
Requirements
7
+
------------
8
+
### Platforms
9
+
- Debian, Ubuntu
10
+
- CentOS, Red Hat, Fedora
17
11
18
-
* build-essential
19
-
* yum
12
+
### Cookbooks
13
+
- build-essential
14
+
- yum
20
15
21
16
NOTE: The `yum` cookbook is a dependency of the cookbook, and will be used to install [EPEL](http://fedoraproject.org/wiki/EPEL) on RedHet/CentOS 5.x systems to provide the Python 2.6 packages.
22
17
23
-
Attributes
24
-
==========
25
18
19
+
Attributes
20
+
----------
26
21
See `attributes/default.rb` for default values.
27
22
28
-
*`node["python"]["install_method"]` - method to install python with, default `package`.
23
+
-`node["python"]["install_method"]` - method to install python with, default `package`.
29
24
30
25
The file also contains the following attributes:
31
26
32
-
* platform specific locations and settings.
33
-
* source installation settings
27
+
- platform specific locations and settings
28
+
- source installation settings
34
29
35
-
Resource/Provider
36
-
=================
37
30
31
+
Resource/Provider
32
+
-----------------
38
33
This cookbook includes LWRPs for managing:
39
34
40
-
* pip packages
41
-
* virtualenv isolated Python environments
42
-
43
-
`python_pip`
44
-
------------
35
+
- pip packages
36
+
- virtualenv isolated Python environments
45
37
38
+
### `python_pip`
46
39
Install packages using the new hotness in Python package management...[`pip`](http://pypi.python.org/pypi/pip). Yo dawg...easy_install is so 2009, you better ask your local Pythonista if you don't know! The usage semantics are like that of any normal package provider.
47
40
48
-
# Actions
49
-
41
+
#### Actions
50
42
- :install: Install a pip package - if version is provided, install that specific version (default)
51
43
- :upgrade: Upgrade a pip package - if version is provided, upgrade to that specific version
52
44
- :remove: Remove a pip package
53
45
- :user: User to run pip as, for using with virtualenv
54
46
- :group: Group to run pip as, for using with virtualenv
55
47
- :purge: Purge a pip package (this usually entails removing configuration files as well as the package itself). With pip packages this behaves the same as `:remove`
56
48
57
-
# Attribute Parameters
58
-
49
+
#### Attribute Parameters
59
50
- package_name: name attribute. The name of the pip package to install
60
51
- version: the version of the package to install/upgrade. If no version is given latest is assumed.
61
52
- virtualenv: virtualenv environment to install pip package into
62
53
- options: Add additional options to the underlying pip package command
63
54
- timeout: timeout in seconds for the command to execute. Useful for pip packages that may take a long time to install. Default 900 seconds.
64
55
65
-
# Example
66
-
67
-
# install latest gunicorn into system path
68
-
python_pip "gunicorn"
69
-
70
-
# target a virtualenv
71
-
python_pip "gunicorn" do
72
-
virtualenv "/home/ubunut/my_ve"
73
-
end
74
-
75
-
# install Django 1.1.4
76
-
python_pip "django" do
77
-
version "1.1.4"
78
-
end
79
-
80
-
# use this provider with the core package resource
81
-
package "django" do
82
-
provider Chef::Provider::PythonPip
83
-
end
84
-
85
-
`python_virtualenv`
86
-
-------------------
87
-
56
+
#### Examples
57
+
```ruby
58
+
# install latest gunicorn into system path
59
+
python_pip "gunicorn"
60
+
61
+
# target a virtualenv
62
+
python_pip "gunicorn"do
63
+
virtualenv "/home/ubunut/my_ve"
64
+
end
65
+
```
66
+
67
+
```ruby
68
+
# install Django 1.1.4
69
+
python_pip "django"do
70
+
version "1.1.4"
71
+
end
72
+
```
73
+
74
+
```ruby
75
+
# use this provider with the core package resource
76
+
package "django"do
77
+
provider Chef::Provider::PythonPip
78
+
end
79
+
```
80
+
81
+
### `python_virtualenv`
88
82
[`virtualenv`](http://pypi.python.org/pypi/virtualenv) is a great tool that creates isolated python environments. Think of it as RVM without all those hipsters and tight jeans.
89
83
90
-
# Actions
91
-
84
+
#### Actions
92
85
- :create: creates a new virtualenv
93
86
- :delete: deletes an existing virtualenv
94
87
95
-
# Attribute Parameters
96
-
88
+
#### Attribute Parameters
97
89
- path: name attribute. The path where the virtualenv will be created
98
90
- interpreter: The Python interpreter to use. default is null (i.e. use whatever python the virtualenv command is using).
99
91
- owner: The owner for the virtualenv
100
92
- group: The group owner of the file (string or id)
101
93
- options : Command line options (string)
102
94
103
-
# Example
104
-
105
-
# create a 2.6 virtualenv owned by ubuntu user
106
-
python_virtualenv "/home/ubuntu/my_cool_ve" do
107
-
owner "ubuntu"
108
-
group "ubuntu"
109
-
action :create
110
-
end
111
-
112
-
# create a Python 2.4 virtualenv
113
-
python_virtualenv "/home/ubuntu/my_old_ve" do
114
-
interpreter "python2.4"
115
-
owner "ubuntu"
116
-
group "ubuntu"
117
-
action :create
118
-
end
119
-
120
-
# create a Python 2.6 virtualenv with access to the global packages owned by ubuntu user
121
-
python_virtualenv "/home/ubuntu/my_old_ve" do
122
-
owner "ubuntu"
123
-
group "ubuntu"
124
-
options "--system-site-packages"
125
-
action :create
126
-
end
95
+
#### Examples
96
+
```ruby
97
+
# create a 2.6 virtualenv owned by ubuntu user
98
+
python_virtualenv "/home/ubuntu/my_cool_ve"do
99
+
owner "ubuntu"
100
+
group "ubuntu"
101
+
action :create
102
+
end
103
+
```
104
+
105
+
```ruby
106
+
# create a Python 2.4 virtualenv
107
+
python_virtualenv "/home/ubuntu/my_old_ve"do
108
+
interpreter "python2.4"
109
+
owner "ubuntu"
110
+
group "ubuntu"
111
+
action :create
112
+
end
113
+
```
114
+
115
+
```ruby
116
+
# create a Python 2.6 virtualenv with access to the global packages owned by ubuntu user
117
+
python_virtualenv "/home/ubuntu/my_old_ve"do
118
+
owner "ubuntu"
119
+
group "ubuntu"
120
+
options "--system-site-packages"
121
+
action :create
122
+
end
123
+
```
127
124
128
-
Usage
129
-
=====
130
-
131
-
default
132
-
-------
133
125
126
+
Usage
127
+
-----
128
+
### default
134
129
Include default recipe in a run list, to get `python`, `pip` and `virtualenv`. Installs python by package or source depending on the platform.
135
130
136
-
package
137
-
-------
138
-
131
+
### package
139
132
Installs Python from packages.
140
133
141
-
source
142
-
------
143
-
134
+
### source
144
135
Installs Python from source.
145
136
146
-
pip
147
-
---
148
-
137
+
### pip
149
138
Installs `pip` from source.
150
139
151
-
virtualenv
152
-
----------
140
+
### virtualenv
153
141
154
142
Installs virtualenv using the `python_pip` resource.
0 commit comments