From: Tom Hughes Date: Tue, 15 Jan 2019 20:24:15 +0000 (+0000) Subject: Install a virtualenv for OSQA X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/24ff6e33b025aedeea2db4655bec734089731b8e?hp=1269b473221f4b6c5f7beee400092c9620fc79fb Install a virtualenv for OSQA --- diff --git a/cookbooks/osqa/recipes/default.rb b/cookbooks/osqa/recipes/default.rb index e70378aed..6ab25051b 100644 --- a/cookbooks/osqa/recipes/default.rb +++ b/cookbooks/osqa/recipes/default.rb @@ -22,16 +22,53 @@ include_recipe "apache" 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" diff --git a/cookbooks/python/recipes/default.rb b/cookbooks/python/recipes/default.rb index 6a1925e01..731081acb 100644 --- a/cookbooks/python/recipes/default.rb +++ b/cookbooks/python/recipes/default.rb @@ -22,3 +22,5 @@ package "python-pip" package "python3" package "python3-pip" + +package "python-virtualenv" diff --git a/cookbooks/python/resources/package.rb b/cookbooks/python/resources/package.rb index 4a3cb9f01..fb9cf09bd 100644 --- a/cookbooks/python/resources/package.rb +++ b/cookbooks/python/resources/package.rb @@ -22,6 +22,7 @@ default_action :install 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 @@ end 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 diff --git a/cookbooks/python/resources/virtualenv.rb b/cookbooks/python/resources/virtualenv.rb new file mode 100644 index 000000000..6ffaccac0 --- /dev/null +++ b/cookbooks/python/resources/virtualenv.rb @@ -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