PyPI 包的可选依赖项 [英] Optional dependencies for PyPI packages

查看:57
本文介绍了PyPI 包的可选依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个新的 PyPI 包,但这将有一个特殊的轮子,我将在其中调用它这个:

I want to create a new PyPI package, but this will have an special wheels where I will invoke it like this:

pip install misoftware[customer1]

这可能吗?

如果是这样,我如何为 [customer1]

If so how can I provide patches for [customer1]

例如我的主要版本是:

misoftware==1.1

misoftware[customer1]

我想要

misoftware[customer1]==1.1.2

总共有 3 个轮子

推荐答案

您正在描述 setuptools '附加'.这允许您指定其他依赖项,例如

You're describing setuptools 'extras'. This allows you to specify additional dependencies, so for example

  • misoftware 只安装misoftware
  • misoftware[customer1] 将安装 misoftware 包,以及一些额外的依赖项
  • misoftware just installs the misoftware package
  • misoftware[customer1] would install the misoftware package, plus some extra dependencies

缺点是您在 extras 中列出的依赖项本身也必须作为包托管在 PyPI 上.因此,您需要创建一个 misoftware_customer1 包,依此类推.

The downside is that the dependencies you list in your extras must be hosted as packages themselves as well on PyPI. So you'd need to create a misoftware_customer1 package, and so on.

这篇关于PyPI 包的可选依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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