【问题标题】:pip - How to use pre-built wheel instead of pulling git again to avoid conflict?pip - 如何使用预先构建的轮子而不是再次拉动 git 以避免冲突?
【发布时间】:2022-01-24 03:47:36
【问题描述】:

上下文
在我的 Django 项目(基于 Django cookiecutter)中,我使用 django-graphql-auth,它依赖于 django-graphql-jwt
我 fork django-graphql-jwt 进行一些更改,然后还 fork django-graphql-auth 以更新其对我的 django-graphql-jwt fork 的依赖:

# django-graphql-auth setup.py
install_requires=[
    "django-graphql-jwt @ git+<git_url>#egg=django_graphql_jwt",
    ...,
]

这与pip install -r requirements.txt 一样正常工作。

问题
在 Docker 中,当我在一个阶段构建轮子并在另一个阶段安装它们时,django-graphql-jwt git 被拉两次(在构建和安装时)并发生冲突。
Cookiecutter Django 提供了一个 Dockerfile (found here),它分为多个阶段:

  1. 为所有依赖项构建轮子。这是克隆和构建 -auth 和 -jwt git 的时候。
> pip wheel --wheel-dir /wheels/ -r local.txt
  1. 从前一阶段复制并安装轮子。在这里,应该使用内置的轮子(不要克隆 git)。
> pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/*
...
Processing /wheels/django_graphql_auth-0.3.16-py2.py3-none-any.whl
Processing /wheels/django_graphql_jwt-0.3.4-py3-none-any.whl
...
Collecting django-graphql-jwt@ git+<git url>
    Cloning ...
...
ERROR: Cannot install django-graphql-auth==0.3.16 and django-graphql-jwt 0.3.4 (from /wheels/django_graphql_jwt-0.3.4-py3-none-any.whl) because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested django-graphql-jwt 0.3.4 (from /wheels/django_graphql_jwt-0.3.4-py3-none-any.whl)
    django-graphql-auth 0.3.16 depends on django-graphql-jwt (unavailable)

您可以看到现有的 -jwt 轮子已被处理,但之后,它的 git 被克隆。这两个似乎导致了冲突。如果我在 setup.py (django-graphql-jwt&gt;=0.3.4) 中添加一个版本,它在构建步骤中已经失败。

如何将 -auth 依赖项与已构建的 -jwt 轮子相匹配?

【问题讨论】:

    标签: python git docker pip python-wheel


    【解决方案1】:

    假设所有必需的依赖项都在第一步中构建(使用pip wheel),您可以通过将--no-deps 选项添加到pip install 来忽略安装步骤中的依赖项:

    pip install --no-cache-dir --no-index --no-deps --find-links=/wheels/ /wheels/*
    

    【讨论】:

      猜你喜欢
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-16
      • 2016-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多