简体   繁体   English

将Python和依赖项部署到Elastic Beanstalk

[英]Deploying Python and Dependencies to Elastic Beanstalk

I have two python projects that share some common libraries all organized into three git repositories: project1, project2, and common-lib. 我有两个共享某些公共库的python项目,这些库都组织成三个git存储库:project1,project2和common-lib。 The two projects are each meant to be deployed to elastic beanstalk bundled with common-lib. 这两个项目分别打算部署到与common-lib捆绑在一起的弹性beantalk中。

I'm trying to find the most idiomatic way to structure these projects to make it easy to develop for locally and to build a zip file for deployment using eb deploy . 我正在尝试找到最惯用的方式来构造这些项目,以使其易于在本地开发并使用eb deploy构建用于部署的zip文件。

Setting everything up for local development is easy. 为本地开发做好一切准备很容易。 Just checkout each repo and do a python setup.py develop in common-lib to make the common libraries available in the virtualenv. 只需签出每个仓库,并在common-lib中进行python setup.py develop ,以使通用库在virtualenv中可用。

For EB deployment it would be nice to have a single setup.py command that produces an EB compatible zip file that contains the project and common-lib with a requirements.txt file that lists the pip dependencies for both. 对于EB部署,最好使用一个setup.py命令来生成EB兼容的zip文件 ,该zip文件包含项目和common-lib,并带有requirements.txt文件,其中列出了两者的pip依赖性。 I have not yet found an easy way to do this which is a bit surprising because I imagine this is a fairly common scenario. 我还没有找到一种简单的方法来执行此操作,这有点令人惊讶,因为我认为这是一个相当普遍的情况。

I can't specify the git repository for common-lib in either project1 or project2's requirements.txt file because the repository won't be reachable from AWS. 我无法在project1或project2的requirements.txt文件中为common-lib指定git存储库,因为该存储库无法从AWS进行访问。

For me the proper way would be to create a python package from the common lib, publish it to a private pypi server, like https://gemfury.com/l/pypi-server . 对我而言,正确的方法是从公共库中创建一个python包,然后将其发布到私有pypi服务器,例如https://gemfury.com/l/pypi-server Have it as a reference in requirements.txt as a python package. 将其作为python软件包作为requirements.txt中的参考。

Another solution can be to include the common-lib as a git submodule https://git-scm.com/docs/git-submodule . 另一个解决方案可以是将common-lib包含为git子模块https://git-scm.com/docs/git-submodule With that you will have the separation, because it will live in a separate repository and you will have a simple reference as a git submodule in your's project. 有了它,您将获得隔离,因为它将存在于单独的存储库中,并且在您的项目中将有一个简单的引用作为git子模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM