如何根据要求pip安装git存储库 [英] How to pip install git repository with requirements

查看:82
本文介绍了如何根据要求pip安装git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个通用的库,看起来像:

So I have a common library repository which looks something like:

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

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

In a separate project I have it in requirements.txt like this:

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

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

When I do pip install it installs it to:

venv
    src
        common

问题在于,公共库有其自己的requirements.txt文件.

The problem is, the common library has its own requirements.txt file.

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

How to tell pip to install requirements of the external library?

推荐答案

通过pip安装时,它使用已下载软件包的setup.py查找依赖项,而不是运行"-r requirements.txt".

When you pip install it uses setup.py of the downloaded package to find dependencies, as opposed to running "-r requirements.txt".

更改通用名称的setup.py来定义依赖项.

Changing the setup.py of common to define dependencies is what you're after.

有关在setup.py文件中定义install_requires的示例,请参见

For an example of defining install_requires in your setup.py file, see the Hitchhiker's Guide to Packaging.

这篇关于如何根据要求pip安装git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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