使用virtualenv进行Python部署(在无Internet访问服务器上) [英] Python deployment with virtualenv (on a no-internet-access server)

查看:376
本文介绍了使用virtualenv进行Python部署(在无Internet访问服务器上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的生产服务器无法访问互联网,所以将所有依赖关系从我的开发机器复制到生产/开发服务器是有点麻烦。

My production server has no access to the internet, so it's a bit a mess copying all the dependencies from my dev machine to the production/development server.

如果我会使用virtualenv,我会在这个环境中拥有所有的依赖项。这样做,我也可以在任何一台机器上部署它,其中有python& virtualenv已安装。

If I'd use virtualenv, I'd have all my dependencies in this environment. Doing this I'd also be able to deploy it on any machine, which has python & virtualenv installed.

但是我很少看到这个,看起来很脏。
我错了,这可能是一个很好的做法,还是有其他方法可以很好的解决?

But I've seen this rarely, and it seems kind of dirty. Am I wrong and this could be a good practice, or are there other ways to solve that nicely?

推荐答案

我会考虑的三个选择:


  1. 运行您自己的 PyPI镜像与您需要的依赖关系。您真的只需要使用 index-url 标记来构建文件布局并从本地服务器中拉取:

  1. Run your own PyPI mirror with the dependencies you need. You really only need to build the file layout and pull from your local server using the index-url flag:

$ pip install --index-url http://pypi.beastcraft.net/ numpy

在相同的架构上构建virtualenvs,并根据需要复制它们。

Build virtualenvs on the same architecture and copy those over as needed.

这是有效的,但您正冒着真正的可移植性的风险。

This works, but you're taking a risk on true portability.

使用 terrarium 构建虚拟环境,然后将其覆盖(基本上是选项2,但更方便的簿记/自动化)。

Use terrarium to build virtual environments then bring those over (basically option 2 but with easier bookkeeping/automation).

我已经完成了所有这些,实际上认为托管自己的PyPI镜是最好的选择。当您进行部署或尝试新的代码时,它可以提供最大的灵活性。

I've done all of these and actually think that hosting your own PyPI mirror is the best option. It gives you the most flexibility when you're making a deployment or trying out new code.

这篇关于使用virtualenv进行Python部署(在无Internet访问服务器上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆