From d565498634e7c8ce3554d1fda505bcbfabab2709 Mon Sep 17 00:00:00 2001 From: Rodolphe Blancho Date: Wed, 23 May 2012 20:18:36 +0200 Subject: [PATCH 1/2] Added 'options' for virtualenv command. Sometimes it is desirable to pass command line options to virtualenv (such as --system-site-packages), so I added an 'options' to the virtualenv resources (the same way as the pip command) --- providers/virtualenv.rb | 2 +- resources/virtualenv.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/virtualenv.rb b/providers/virtualenv.rb index 22f2b7b..d10f099 100644 --- a/providers/virtualenv.rb +++ b/providers/virtualenv.rb @@ -25,7 +25,7 @@ action :create do unless exists? Chef::Log.info("Creating virtualenv #{@new_resource} at #{@new_resource.path}") - execute "#{virtualenv_cmd} --python=#{@new_resource.interpreter} #{@new_resource.path}" do + execute "#{virtualenv_cmd} --python=#{@new_resource.interpreter} #{@new_resource.options} #{@new_resource.path}" do user new_resource.owner if new_resource.owner group new_resource.group if new_resource.group end diff --git a/resources/virtualenv.rb b/resources/virtualenv.rb index c5840a2..7803c14 100644 --- a/resources/virtualenv.rb +++ b/resources/virtualenv.rb @@ -24,3 +24,4 @@ attribute :interpreter, :default => 'python2.6' attribute :owner, :regex => Chef::Config[:user_valid_regex] attribute :group, :regex => Chef::Config[:group_valid_regex] +attribute :options, :kind_of => String From 5c8019ad1d3438d823b3d276f9997970b72ab675 Mon Sep 17 00:00:00 2001 From: Rodolphe Blancho Date: Thu, 24 May 2012 12:15:04 +0200 Subject: [PATCH 2/2] [COOK-1113] Added doc for virtualenv options in README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 7af44ae..b05dda8 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ Install packages using the new hotness in Python package management...[`pip`](ht - interpreter: The Python interpreter to use. default is `python2.6` - owner: The owner for the virtualenv - group: The group owner of the file (string or id) +- options : Command line options (string) # Example @@ -116,6 +117,14 @@ Install packages using the new hotness in Python package management...[`pip`](ht action :create end + # create a Python 2.6 virtualenv with access to the global packages owned by ubuntu user + python_virtualenv "/home/ubuntu/my_old_ve" do + owner "ubuntu" + group "ubuntu" + options "--system-site-packages" + action :create + end + Usage =====