简体   繁体   English

如何禁止将软件包添加到Pipenv.lock并由Pipenv安装?

[英]How can I ban a package from being added to Pipenv.lock and installed by Pipenv?

There are two packages which provide a module named jsonfield : 有两个软件包提供了一个名为jsonfield的模块:

Unfortunately, we have dependencies which depend on both and the two packages, while interchangable, store data to the database differently. 不幸的是,我们有依赖于这两个软件包的依赖关系,尽管它们可以互换,但它们将数据存储到数据库的方式有所不同。 This leads to weird and hard to catch bugs . 这导致怪异且难以发现错误 Also, unfortunately, Pipenv doesn't have any deterministic order of operations when installing dependencies. 另外,不幸的是,Pipenv在安装依赖项时没有确定的操作顺序。 Sometimes django-jsonfield is installed and sometimes jsonfield is installed. 有时会安装django-jsonfield ,有时会安装jsonfield This means that sometimes, randomly, our application breaks because jsonfield is installed instead of django-jsonfield . 这意味着有时,由于安装了jsonfield而不是django-jsonfield ,我们的应用程序有时会中断。

Is there a way that I can ban django-jsonfield from being added to Pipenv.lock so that only jsonfield will be installed? 有没有一种方法可以禁止将django-jsonfield添加到Pipenv.lock以便仅安装jsonfield

From the looks of it, you are in quite a tricky situation... There is no clean solution that I know of currently other than manually editing your Pipfile.lock after each time it is generated. 从外观Pipfile.lock ,您处在一个棘手的情况下……除了每次生成后手动编辑Pipfile.lock之外,我目前还没有干净的解决方案。

You really should talk to the developers of the culprit projects: 您确实应该与罪魁祸首项目的开发人员交谈:

  • Either jsonfield and django-jsonfield should agree on different names for their top level packages. jsonfielddjango-jsonfield的顶级软件包都应使用不同的名称。
  • Or the projects that depend on jsonfield or django-jsonfield should agree on one of the two and ditch the other one. 或者,依赖于jsonfielddjango-jsonfield应就两者之一达成共识,而django-jsonfield另一个。

You might be interested in this discussion and eventually weigh in: https://github.com/pypa/packaging-problems/issues/154 . 您可能对此讨论感兴趣并最终参与讨论: https : //github.com/pypa/packaging-problems/issues/154 Of particular interest in your case is the fact that pip allows the overwriting of an already installed package when installing a new one. 在您的情况下,特别有趣的是pip允许在安装新软件包时覆盖已安装的软件包。


Untested : 未经测试

You could experiment with setting an unlikely marker on the unwanted dependency: 您可以尝试在不必要的依赖项上设置一个不太可能的标记:

django-jsonfield = { markers="python_version < '2'" }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM