diff options
author | Marc Fournier <marc.fournier@camptocamp.com> | 2012-11-06 21:23:46 +0100 |
---|---|---|
committer | Marc Fournier <marc.fournier@camptocamp.com> | 2012-11-06 21:23:46 +0100 |
commit | 5477c34707d6d59b4e7fd0a77c87183b59c37e52 (patch) | |
tree | 7d02c1c8ddac7d7a90118a6e34d70339d89c4ab4 | |
parent | 452451e8f5c0bd40b867088f481c130a21efb0a1 (diff) |
python::virtualenv - '--system-site-packages' option
New 'systempkgs' parameter will call virtualenv with the
'--system-site-packages' option, which can greatly speed up creation in
some cases.
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | manifests/virtualenv.pp | 14 | ||||
-rw-r--r-- | tests/virtualenv.pp | 1 |
3 files changed, 16 insertions, 2 deletions
@@ -64,11 +64,14 @@ Creates Python virtualenv. **proxy** — Proxy server to use for outbound connections. Default: none +**systempkgs** — Copy system site-packages into virtualenv. Default: don't + python::virtualenv { '/var/www/project1': ensure => present, version => 'system', requirements => '/var/www/project1/requirements.txt', proxy => 'http://proxy.domain.com:3128', + systempkgs => true, } ### python::gunicorn diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index f22f4e1..e286699 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -16,6 +16,9 @@ # [*proxy*] # Proxy server to use for outbound connections. Default: none # +# [*systempkgs*] +# Copy system site-packages into virtualenv. Default: don't +# # === Examples # # python::virtualenv { '/var/www/project1': @@ -23,6 +26,7 @@ # version => 'system', # requirements => '/var/www/project1/requirements.txt', # proxy => 'http://proxy.domain.com:3128', +# systempkgs => true, # } # # === Authors @@ -33,7 +37,8 @@ define python::virtualenv ( $ensure = present, $version = 'system', $requirements = false, - $proxy = false + $proxy = false, + $systempkgs = false, ) { $venv_dir = $name @@ -55,10 +60,15 @@ define python::virtualenv ( default => "&& export http_proxy=${proxy}", } + $system_pkgs_flag = $systempkgs ? { + false => '', + default => '--system-site-packages', + } + exec { "python_virtualenv_${venv_dir}": command => "mkdir -p ${venv_dir} \ ${proxy_command} \ - && virtualenv -p `which ${python}` ${venv_dir} \ + && virtualenv -p `which ${python}` ${system_pkgs_flag} ${venv_dir} \ && ${venv_dir}/bin/pip install ${proxy_flag} --upgrade distribute pip", creates => $venv_dir, } diff --git a/tests/virtualenv.pp b/tests/virtualenv.pp index 190492c..da5ab57 100644 --- a/tests/virtualenv.pp +++ b/tests/virtualenv.pp @@ -9,4 +9,5 @@ python::virtualenv { '/var/www/project1': version => 'system', requirements => '/var/www/project1/requirements.txt', proxy => 'http://proxy.domain.com:3128', + systempkgs => true, } |