如何在 Windows 上将 pytorch 指定为包要求? [英] How to specify pytorch as a package requirement on windows?

查看:29
本文介绍了如何在 Windows 上将 pytorch 指定为包要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖 pytorch 的 python 包,我希望 Windows 用户能够通过 pip 安装它(具体包是:https://github.com/mindsdb/lightwood,但我认为这与我的问题不太相关.

I have a python package which depends on pytorch and which I’d like windows users to be able to install via pip (the specific package is: https://github.com/mindsdb/lightwood, but I don’t think this is very relevant to my question).

解决此问题的最佳做法是什么?

What are the best practices for going about this ?

有什么项目可以作为例子吗?

Are there some project I could use as examples ?

看起来像torch&的pypi托管版本torchvision 与 Windows 不兼容,入门"部分建议从自定义 pytorch 存储库安装,但除此之外,我不确定将其作为安装脚本的一部分的理想解决方案是什么.

It seems like the pypi hosted version of torch & torchvision aren’t windows compatible and the "getting started" section suggests installing from the custom pytorch repository, but beyond that I’m not sure what the ideal solution would be to incorporate this as part of a setup script.

推荐答案

解决此问题的最佳做法是什么?

What are the best practices for going about this ?

如果您的项目依赖于未通过 PyPI 分发的其他项目,那么您必须以某种方式通知您的项目用户.我推荐以下组合:

If your project depends on other projects that are not distributed through PyPI then you have to inform the users of your project one way or another. I recommend the following combination:

  • 明确指定(在项目的文档页面、项目的详细描述README 或类似内容中)哪些依赖项不能通过 PyPI 获得(以及可能的原因,带有适当的链接)以及获取它们的可能位置;
  • 为了提升用户体验,请与您的项目一起发布预先准备好的requirements.txt 文件,带有适当的 --find-links 选项.
  • clearly specify (in your project's documentation pages, or in the project's long description, or in the README, or anything like this) which dependencies are not available through PyPI (and possibly the reason why, with the appropriate links) as well as the possible locations to get them from;
  • to facilitate the user experience, publish alongside your project a pre-prepared requirements.txt file with the appropriate --find-links options.

原因(或主要原因,还有其他原因)是,任何使用 pip 的人都假定(默认情况下)所有内容都将从 PyPI 下载,而不会从其他任何地方下载.换句话说,任何使用 pip 的人都信任 pypi.org 作为 Python 项目分发的来源.如果 pip 突然从其他来源下载工件,就会破坏这种信任.从其他来源下载应由用户决定.

The reason why (or main reason, there are others), is that anyone using pip assumes that (by default) everything will be downloaded from PyPI and nowhere else. In other words anyone using pip puts some trust into pypi.org as a source for Python project distributions. If pip were suddenly to download artifacts from other sources, it would breach this trust. It should be the user's decision to download from other sources.

因此,您可以在项目文档中提供一个 requirements.txt 文件示例,如下所示:

So you could provide in your project's documentation an example of requirements.txt file like the following:

# ...
torch===1.4.0  --find-links https://download.pytorch.org/whl/torch_stable.html
torchvision===0.5.0  --find-links https://download.pytorch.org/whl/torch_stable.html
# ...

<小时>

更新

最好的解决方案是帮助相关项目的维护者直接在 PyPI 上发布 Windows wheels :

The best solution would be to help the maintainers of the projects in question to publish Windows wheels on PyPI directly:

这篇关于如何在 Windows 上将 pytorch 指定为包要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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