我第一次使用Chalice,因为我试图将它评估为可能的替代框架,以将我现有的 Python Flask API 从 EC2 迁移到 Lambda。
从一个 Amazon Linux EC2 实例中,我将一些依赖项添加到我正在使用的 virtualenv 中。然后我创建了一个 requirements.txt:
botocore==1.7.11
chalice==1.0.2
click==6.6
docutils==0.14
jmespath==0.9.3
MySQL-python==1.2.5
PyMySQL==0.7.11
python-dateutil==2.6.1
six==1.10.0
SQLAlchemy==1.1.14
typing==3.5.3.0
然后我尝试部署chalice deploy
并得到:
Creating deployment package.
Could not install dependencies:
MySQL-python==1.2.5
typing==3.5.3.0
You will have to build these yourself and vendor them in
the chalice vendor folder.
Your deployment will continue but may not work correctly
if missing dependencies are not present. For more information:
http://chalice.readthedocs.io/en/latest/topics/packaging.html
........
然后,我尝试按照链接的文档进行操作,对于第一个有问题的依赖项MySQL-python==1.2.5
,我执行了以下操作:
cd vendor/
pip download MySQL-python==1.2.5
pip wheel MySQL-python-1.2.5.zip
rm rm MySQL-python-1.2.5.zip
unzip MySQL_python-1.2.5-cp27-cp27mu-linux_x86_64.whl
rm MySQL_python-1.2.5-cp27-cp27mu-linux_x86_64.whl
我的供应商文件夹如下所示:
ls vendor
MySQLdb _mysql_exceptions.py MySQL_python-1.2.5.dist-info _mysql.so
现在当我运行 chalice deploy 我得到:
(test)[ec2-user@ip-172-31-26-155 test]$ chalice deploy
Creating deployment package.
Could not install dependencies:
MySQL-python==1.2.5
You will have to build these yourself and vendor them in
the chalice vendor folder.
Your deployment will continue but may not work correctly
if missing dependencies are not present. For more information:
http://chalice.readthedocs.io/en/latest/topics/packaging.html
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: '_mysql.so'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: '_mysql_exceptions.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQL_python-1.2.5.dist-info/RECORD'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQL_python-1.2.5.dist-info/DESCRIPTION.rst'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQL_python-1.2.5.dist-info/WHEEL'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQL_python-1.2.5.dist-info/top_level.txt'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQL_python-1.2.5.dist-info/METADATA'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQL_python-1.2.5.dist-info/metadata.json'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/converters.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/release.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/__init__.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/cursors.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/times.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/connections.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/REFRESH.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/CLIENT.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/ER.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/FIELD_TYPE.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/__init__.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/CR.py'
zipped.write(full_path, zip_path)
/home/ec2-user/test/test/local/lib/python2.7/site-packages/chalice/deploy/packager.py:110: UserWarning: Duplicate name: 'MySQLdb/constants/FLAG.py'
zipped.write(full_path, zip_path)
从文档中,我不清楚我做错了什么。有人可以帮忙吗?