【问题标题】:How to pip install git repository with requirements如何根据要求 pip 安装 git 存储库
【发布时间】:2014-01-01 21:49:12
【问题描述】:

所以我有一个公共库存储库,看起来像:

common
    __init__.py
    foo
        __init__.py
        bar.py
README.md
requirements.txt
setup.py

在一个单独的项目中,我将它放在 requirements.txt 中,如下所示:

git+https://github.com/something/something.git#egg=common

当我执行 pip install 时,它会将其安装到:

venv
    src
        common

问题是,通用库有自己的 requirements.txt 文件。

如何告诉 pip 安装外部库的需求?

【问题讨论】:

  • 为什么不在setup.py 中定义库的要求(在setup 调用中,requires arg)。

标签: python pip


【解决方案1】:

当您 pip install 时,它使用下载包的setup.py 来查找依赖项,而不是运行"-r requirements.txt"

改变 setup.py 的 common 来定义依赖是你所追求的。

有关在setup.py 文件中定义install_requires 的示例,请参阅Hitchhiker's Guide to Packaging

【讨论】:

    【解决方案2】:

    pip -r <file|url> 支持本地文件或 url。例如:

    pip install -r http://localhost:8080/requirements.txt
    

    经过测试和确认。

    【讨论】:

      猜你喜欢
      • 2012-12-19
      • 2018-11-29
      • 2014-11-13
      • 1970-01-01
      • 2021-07-07
      • 2014-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多