我们有一个不包含代码的占位符 egg,它的存在只是为了从我们的 PyPi 存储库中拉下依赖包的列表。
这些依赖包中的大多数与平台无关,但有些仅用于 Win32 平台。
是否有可能以某种方式使依赖平台成为条件,以便我的 install_requires
列表中的给定依赖项只会在 Win32 上安装时被拉下?
或者:是否可以指定一个可选依赖项列表,如果可用则安装,但如果不可用则不会导致 easy_install
失败?
最佳答案
对于 sdist、egg 和 wheel 发布自:https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#platform-specific-dependencies
Sometimes a project might require a dependency to run on a specific platform. This could to a package that back ports a module so that it can be used in older python versions. Or it could be a package that is required to run on a specific operating system. This will allow a project to work on multiple different platforms without installing dependencies that are not required for a platform that is installing the project.
setup(
name="Project",
...
install_requires=[
'enum34 ; python_version<"3.4"',
'pywin32 >= 1.0 ; platform_system=="Windows"'
]
)
关于python - 是否可以在 setup.py 中表达特定于平台的依赖项,而无需构建我的 egg 的特定于平台的版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6469508/