是否可以在setup.py中表达特定于平台的依赖关系而无需构建我的egg的特定于平台的版本? [英] Is it possible to express a platform-specific dependency in setup.py without building platform-specific versions of my egg?

查看:65
本文介绍了是否可以在setup.py中表达特定于平台的依赖关系而无需构建我的egg的特定于平台的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个占位符鸡蛋,其中不包含任何代码,仅是为了从我们的PyPi存储库中提取依赖包列表而存在。

We have a placeholder egg that contains no code and only exists for the sake of pulling down a list of dependent packages from our PyPi repository.

其中大多数依赖包程序包与平台无关,但是某些程序包仅在Win32平台上使用。

Most of these dependent packages are platform-agnostic, however some are only used on Win32 platforms.

是否有可能使依赖项成为平台条件,以便在我的 install_requires 列表仅在Win32上安装时会被拉下吗?

Is it possible to somehow make the dependency platform-conditional, so that a given dependency in my install_requires list will only get pulled down when installing on Win32?

或者:可以指定一个可选依赖项列表,如果可用,将安装这些依赖项,但如果不存在,它们不会导致 easy_install 失败吗?

Alternatively: Is it possible to specify a list of optional dependencies, that will be installed if available, but will not cause easy_install to fail if they are not?

推荐答案

使用 extras_require 分发选项使 win32支持成为可选功能:

Use the extras_require distribution option to make 'win32 support' an optional feature:

setup(
  ...
  extras_require={
    'win32': 'pywin32'
  },
  ...
)

Th zh_cn在Windows上安装时指定win32功能:

Then specify the win32 feature when installing on Windows:

easy_install mypackage[win32]

这将拉出 pywin32 软件包,该软件包被列为 win32的依赖项

This will pull down the pywin32 package, which is listed as a dependency for the 'win32' feature of mypackage.

请参见此处以了解有关可选功能的更多信息。

See here for more information about optional features.

这篇关于是否可以在setup.py中表达特定于平台的依赖关系而无需构建我的egg的特定于平台的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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