]> git.openstreetmap.org Git - chef.git/commitdiff
Install a virtualenv for OSQA
authorTom Hughes <tom@compton.nu>
Tue, 15 Jan 2019 20:24:15 +0000 (20:24 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 15 Jan 2019 20:26:10 +0000 (20:26 +0000)
cookbooks/osqa/recipes/default.rb
cookbooks/python/recipes/default.rb
cookbooks/python/resources/package.rb
cookbooks/python/resources/virtualenv.rb [new file with mode: 0644]

index e70378aed88ad7bb09580cc09824cfdb4f0b6b3b..6ab25051b02026c42a00015adf01bcab01dfe69a 100644 (file)
@@ -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"
index 6a1925e015bf35d22d1b11074088c0c22d192119..731081acb58352f4ab1154133aa2ca87c7d0d849 100644 (file)
@@ -22,3 +22,5 @@ package "python-pip"
 
 package "python3"
 package "python3-pip"
+
+package "python-virtualenv"
index 4a3cb9f0141a100954dedb838cd2f5ea67afa9f9..fb9cf09bd3fac8fabba6dc9d66a3475cf57d84bc 100644 (file)
@@ -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 (file)
index 0000000..6ffacca
--- /dev/null
@@ -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