以下のようなことを考えた
% mkdir /tmp/py27
% cd /tmp/py27
% (buildout.cfg + bootstrap.pyを用意)
% cat buildout.cfg
[buildout]
python = python
parts =
python
env
[python]
recipe = zc.recipe.cmmi
url = http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
executable = ${buildout:parts-directory}/python/bin/python2.7
environment =
LDFLAGS=-Wl,-rpath,${buildout:parts-directory}/python/lib
extra_options =
--enable-unicode=ucs4
--enable-shared
--with-threads
[env]
recipe = zc.recipe.egg
eggs =
virtualenv
virtualenvwrapper
interpreter = python
% python bootstrap.py
% bin/buildout
% export WORKON_HOME=/tmp/virtualenvs
% export VIRTUALENVWRAPPER_HOOK_DIR=/tmp/virtualenvs
% export VIRTUALENVWRAPPER_LOG_DIR=/tmp/virtualenvs
## FIXME: クリーンな環境でうまくいくか?
% mkvirtualenv -p /tmp/py27/parts/python/bin/python testenv
% /tmp/virtualenvs/testenv/bin/pip install Flask
% /tmp/virtualenvs/testenv/bin/pip install gunicorn
% /tmp/virtualenvs/testenv/bin/pip install supervisor
% cat myserver.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "<h1>hello!Yes!</h1>"
if __name__ == '__main__':
app.run(debug=True)
% /tmp/virtualenvs/testenv/bin/python myserver.py
* Running on http://127.0.0.1:5000/
* Restarting with reloader
cpでinstallしないほうがいい(暫定手順)
% sudo mkdir /tmp/virtualenvs/testenv/lib/python2.7/site-packages/mypj
% touch /tmp/virtualenvs/testenv/lib/python2.7/site-packages/mypj/__init__.py
% sudo cp myserver.py /tmp/virtualenvs/testenv/lib/python2.7/site-packages/mypj/
本当はdaemonモード
% /tmp/virtualenvs/testenv/bin/gunicorn mypj.myserver:app