我该如何在我的PyPI项目的项目链接
部分添加链接?
这个问题之前已经有答案,但是有点难找,所以希望这个问题更容易一些。
PyPI从project_urls
元数据中获取这些链接。
在您的setup.py
文件中,使用标题-URL键值对的字典作为project_urls
参数来调用setuptools.setup()
函数。
import setuptools
project_urls = {
'Link 1': 'https://mygreatsite.com',
'Link 2': 'https://anothersite.com'
}
setuptools.setup( other_arguments, project_urls = project_urls )
如果您想知道在PyPI上使用哪个标识符来表示哪个URL的图标,例如,如果您编写
project_urls = {
'Twitter': 'https://twitter.com/PyScaffold',
}
如果你想在 PyPI 上看到 Twitter 小鸟图标,可以查看例如 https://pypi.org/project/PyScaffold/。
如果要查看可用的图标以及何时设置了这些图标,只需查看此文件 (/warehouse/templates/packaging/detail.html
),源代码来自于 PyPI。
诗歌有点不同, 但是思路相同。
您可以在pyproject.toml文件的主要部分下,使用[tool.poetry]
来放置一些基本信息。例如:
[tool.poetry]
homepage = "https://free.law/projects/x-ray"
repository = "https://github.com/freelawproject/x-ray"
documentation = "https://github.com/freelawproject/x-ray/blob/main/README.md"
如果你想要更多的URL,可以这样做:
[tool.poetry.urls]
"Organisation Homepage" = "https://free.law/"
"Change Log" = "https://github.com/freelawproject/x-ray/blob/main/CHANGES.md"
Issues = "https://github.com/freelawproject/x-ray/issues"
Funding = "https://www.courtlistener.com/donate/?referrer=pypi-xray"
有一系列的特殊值可以为您提供图标,但似乎您可以在此处放置任何内容,Poetry 也将感到高兴。如果 Pypi 不知道链接是什么,它将只会在其旁边放置一个通用图标。
这是可以获得图标的事物列表:
https://github.com/pypi/warehouse/blob/main/warehouse/templates/packaging/detail.html