告诉pip安装需求文件中列出的软件包的依赖项 [英] tell pip to install the dependencies of packages listed in a requirement file

查看:298
本文介绍了告诉pip安装需求文件中列出的软件包的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开发Django网络应用程序,我列出了需要在virtualenv中安装的软件包.说:

Developing a Django web app, I have a list of packages I need to install in a virtualenv. Say:

Django==1.3.1
--extra-index-url=http://dist.pinaxproject.com/dev/
Pinax==0.9b1.dev10
git+git://github.com/pinax/pinax-theme-bootstrap.git@cff4f5bbe9f87f0c67ee9ada9aa8ae82978f9890
# and other packages

最初,我在开发过程中一一手动安装了它们.这样就安装了必需的依赖项,在部署应用程序之前,我最终使用了pip freeze.

Initially I installed them manually, one by one, along the development. This installed the required dependencies and I finally used pip freeze before deploying the app.

问题是,当我升级某些软件包时,不再使用或不需要某些依赖关系,但它们仍被pip freeze列出.

Problem is, as I upgraded some packages, some dependencies are no longer used nor required but they keep being listed by pip freeze.

现在,我想以这种方式设置一个新的virtualenv:

Now, I'd like to set up a new virtualenv this way:

  • 将所需的软件包(不依赖于它们)放在需求文件中,
    就像manual-requirements.txt
  • 使用它们的依赖项安装它们
    pip install -r manual-requirement.txt(←问题,这不会安装依赖项)
  • 冻结完整的virtualenv
    pip freeze -r manual-requirements.txt > full-requirements.txt
    并部署.
  • put the needed packages (without their dependencies) in a requirement file,
    like manual-requirements.txt
  • install them with their dependencies
    pip install -r manual-requirement.txt (← problem, this does not install the dependencies)
  • freeze the full virtualenv
    pip freeze -r manual-requirements.txt > full-requirements.txt
    and deploy.

有什么方法可以在不手动将软件包重新安装到新的virtualenv中的情况下获得它们的依赖关系?这很容易出错,我想自动化从不再需要的旧依赖中清除virtualenv的过程.

Any way to do this without manually re-installing the packages in a new virtualenv to get their dependencies ? This would be error-prone and I'd like to automate the process of cleaning the virtualenv from no-longer-needed old dependencies.

编辑:实际上,pip 确实安装了未在需求文件中明确列出的依赖项,即使

edit: actually, pip does install dependencies not explicitly listed in the requirement file, even if the documentation tells us that such files are flat. I was wrong about which dependencies i expected to be installed. I'll let this question for anyone in doubt about pip not installing all dependencies.

推荐答案

鉴于您对问题的评论(您说对单个软件包执行安装按预期工作),我建议遍历您的需求文件.在bash中:

Given your comment to the question (where you say that executing the install for a single package works as expected), I would suggest looping over your requirement file. In bash:

#!/bin/sh
while read p; do
  pip install $p
done < requirements.pip

HTH!

这篇关于告诉pip安装需求文件中列出的软件包的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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