在没有python-dev的情况下在生产中使用virtualenv

时间:2013-07-28 10:10:11

标签: python virtualenv pip production-environment

我有一个python web项目,我在dev服务器上使用了带有pip的virtualenv。 一些python包需要编译,所以我应该使用python-dev来进行pip安装。 有没有办法在生产中重现我的需求堆栈,保持virtualenv,但没有python-dev,因为我没有处理dev服务器?

1 个答案:

答案 0 :(得分:5)

pip 1.4增加了对安装和构建轮组件的支持。

  

“Wheel”是一种内置的归档格式,与从源档案构建和安装相比,可以大大加快安装速度。

程序

  1. 安装/升级到pip 1.4。 (仅限一次)

  2. 在dev,production server中安装wheel。 (仅限一次)

    pip install wheel
    
  3. 在dev服务器中构建wheel包:

    pip wheel --wheel-dir=/local/wheels -r requirements.txt
    
  4. /local/wheels个包转移到生产服务器。

  5. 在生产服务器中安装包:

    pip install --use-wheel --no-index --find-links=/local/wheels -r requirements.txt
    
  6. 参考

    有关详细信息,请参阅pip documentation about building and installing wheels