谷歌云平台技术解决方案代表Adam:Modules documentations may not be explicitly
stated, but the folder 'Module1', 'Module2' as well as the default
module actually run inside separate Python virtual environments on
separate instances and need to be self contained. They cannot 'see'
any directories above them which exist on the local filesystem, and
'default.py' can't see anything in each of the module directories. The
whole folder tree isn't copied to each module instance.
他建议不要创建符号链接,只需将./lib复制到每个模块。在
我不太喜欢这个主意。在
首先,这些模块共享一些基类,复制它们确实是一种反模式。在
其次,到处复制lib文件夹会破坏单元测试,因为nose会尝试运行它可以运行的所有单元测试,这也是因为显式地排除目录是一件痛苦的事情。在
最后,我写了一个makefile来帮助部署/测试更容易。。。在# Create simlinks before deployment.
deploy: mksimlnks
appcfg.py oauth2 update $(CURDIR)/app.yaml
appcfg.py oauth2 update $(CURDIR)/MODULE_1/module_1.yaml
appcfg.py oauth2 update $(CURDIR)/MODULE_2/module_2.yaml
appcfg.py oauth2 update_queues $(CURDIR)
mksimlnks:
ln -s $(CURDIR)/lib $(CURDIR)/MODULE_1/lib
ln -s $(CURDIR)/lib $(CURDIR)/MODULE_2/lib
# Need to remove symlinks before unittest
# or unit test will explode.
test: rmsimlnks
nosetests exclude-dir=lib with-gae -w $(CURDIR) with-coverage cover-html
# Remove all symlinks
rmsimlnks:
rm -rf $(shell find * -type l)
# remove symlinks and other stuff
clean: rmsimlnks
rm -f $(shell find * -name *.pyc)
rm -f $(shell find * -name .DS_Store)
rm -f .coverage
rm -rf $(CURDIR)/cover