Permalink
Browse files

Install a virtualenv for OSQA

  • Loading branch information...
tomhughes committed Jan 15, 2019
1 parent 1269b47 commit 24ff6e33b025aedeea2db4655bec734089731b8e
@@ -22,16 +22,53 @@
include_recipe "memcached"
include_recipe "python"

package "python-django"
package "python-html5lib"
package "python-markdown"
package "python-memcache"
package "python-openid"
package "python-mysqldb"
package "python-psycopg2"
package "python-setuptools"

python_package "South"
package "python-dev"
package "libmysqlclient-dev"
package "libpq-dev"

python_directory = "/opt/osqa-python"

python_virtualenv python_directory

python_package "django" do
python_virtualenv python_directory
version "1.6.11"
end

python_package "html5lib" do
python_virtualenv python_directory
version "0.999"
end

python_package "markdown" do
python_virtualenv python_directory
version "2.4"
end

python_package "python-memcached" do
python_virtualenv python_directory
version "1.53"
end

python_package "python_openid" do
python_virtualenv python_directory
version "2.2.5"
end

python_package "MySQL_python" do
python_virtualenv python_directory
version "1.2.3"
end

python_package "psycopg2" do
python_virtualenv python_directory
version "2.4.5"
end

python_package "South" do
python_virtualenv python_directory
version "0.7.6"
end

apache_module "rewrite"
apache_module "wsgi"
@@ -22,3 +22,5 @@

package "python3"
package "python3-pip"

package "python-virtualenv"
@@ -22,6 +22,7 @@
property :package_name, :kind_of => String, :name_property => true
property :version, :kind_of => String
property :python_version, :kind_of => String
property :python_virtualenv, :kind_of => String

action :install do
if new_resource.version.nil?
@@ -46,6 +47,10 @@

action_class do
def pip_command
"pip#{new_resource.python_version}"
if new_resource.python_virtualenv
"#{new_resource.python_virtualenv}/bin/pip"
else
"pip#{new_resource.python_version}"
end
end
end
@@ -0,0 +1,36 @@
#
# Cookbook Name:: python
# Resource:: virtualenv
#
# Copyright 2019, OpenStreetMap Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default_action :create

property :virtualenv_directory, :kind_of => String, :name_property => true

action :create do
execute "virtualenv-#{new_resource.virtualenv_directory}" do
command "virtualenv #{new_resource.virtualenv_directory}"
not_if { ::File.exist?(new_resource.virtualenv_directory) }
end
end

action :delete do
directory new_resource.virtualenv_directory do
action :delete
recursive true
end
end

0 comments on commit 24ff6e3

Please sign in to comment.