capistrano-virtualenv
a capistrano recipe to deploy python apps with virtualenv.
Installation
Add this line to your application's Gemfile:
gem 'capistrano-virtualenv'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capistrano-virtualenv
Usage
This recipe will create 2 kind of virtualenv during deploy
task.
- shared virtualenv
- created in
shared_path
afterdeploy:setup
- common libraries are installed here.
- created in
- release virtualenv
- created in
release_path
afterdeploy:finalize_update
- per-release virtualenv that can be rolled back.
- created in
To deploy your application with virtualenv
, add following in you config/deploy.rb
.
# in "config/deploy.rb"
require 'capistrano-virtualenv'
Following options are available to manage your virtualenv.
-
:virtualenv_bootstrap_python
- the python executable which will be used to craete virtualenv. by default "python". -
:virtualenv_current_path
- virtualenv path under:current_path
. -
:virtualenv_current_python
- python path under:virtualenv_current_path
. -
:virtualenv_easy_install_options
- options foreasy_install
. by defaul "--quiet". -
:virtualenv_install_packages
- apt packages dependencies for python. -
:virtualenv_pip_options
- options forpip
. by default "--quiet". -
:virtualenv_pip_install_options
- options forpip install
. -
:virtualenv_release_path
- virtualenv path under:release_path
. -
:virtualenv_release_python
- python path under:virtualenv_release_path
. -
:virtualenv_requirements
- the list ofpip
packages should be installed tovirtualenv
. -
:virtualenv_requirements_file
- the path to the file that describes library dependencies. by default "requirements.txt". -
:virtualenv_script_url
- the download URL ofvirtualenv.py
. -
:virtualenv_shared_path
- virtualenv path under:shared_path
. -
:virtualenv_shared_python
- python path under:virtualenv_shared_path
-
:virtualenv_use_system
- controls whether virtualenv should be use system packages or not. false by default.
Examples
Upgrading base Python version
To upgrade base Python version of virtualenv, you must once remove existing shared virtualenv. Since the shared virtualenv is not referenced from release virtualenv after the creation, you can safely remove the shared virtualenv before and after the deployments.
$ cap virtualenv:destroy_shared # remove existing shared virtualenv
$ cap virtualenv:setup # create virtualenv with new Python version
$ cap deploy
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Author
- YAMASHITA Yuu (https://github.com/yyuu)
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
License
MIT