2014-02-11 19 views
0

對於App Engine項目,我在zc.buildout上遇到了一些困難。我想建立一個bin/生成一個python解釋器,它包含path所需的調整,它基於app.yaml中指定的庫版本。這樣,只要有命令行腳本或交互式shell工作,我就可以使用這個生成的python腳本。如何使用包含我的初始化代碼的zc.buildout生成自定義python解釋器?

這是我想插入的代碼:

import dev_appserver 
dev_appserver.fix_sys_path() 

這裏是我的buildout.cfg:

[buildout] 
parts = 
    python 
    gae_sdk 
[gae_sdk] 
# Downloads and extracts the App Engine SDK. 
recipe = appfy.recipe.gae:sdk 
url = http://googleappengine.googlecode.com/files/google_appengine_1.8.9.zip 
destination = ${buildout:parts-directory} 
hash-name = false 
clear-destination = true 
[python] 
recipe = zc.recipe.egg 
interpreter = python 
initialization = 
    import dev_appserver 
    dev_appserver.fix_sys_path() 
extra-paths = 
    ${gae_sdk:destination}/google_appengine 
    ${buildout:directory}/app 

回答

2

原來我錯過了一些魔法zc.recipe.egg,使其工作正常。這裏是正確的源

[buildout] 
parts = 
    python 
    gae_sdk 
[gae_sdk] 
# Downloads and extracts the App Engine SDK. 
recipe = appfy.recipe.gae:sdk 
url = http://googleappengine.googlecode.com/files/google_appengine_1.8.9.zip 
destination = ${buildout:parts-directory} 
hash-name = false 
clear-destination = true 
[python] 
# use the scripts entry point, not just zc.recipe.egg 
recipe = zc.recipe.egg:scripts 
interpreter = python 
initialization = 
    import dev_appserver 
    dev_appserver.fix_sys_path() 
# even if empty, must be here or else it errors... 
eggs = 
extra-paths = 
    ${gae_sdk:destination}/google_appengine 
    ${buildout:directory}/app 

產生適當的bin/python作爲

#!/usr/local/opt/python/bin/python2.7 
import sys 
sys.path[0:0] = [ 
    '/path/to/awesome/parts/google_appengine', 
    '/path/to/awesome/app', 
    ] 
import dev_appserver 
dev_appserver.fix_sys_path() 
... 
相關問題