【问题标题】:How do I provide a link to a changelog for a package on PyPI?如何为 PyPI 上的包提供更改日志的链接?
【发布时间】:2022-08-09 16:29:22
【问题描述】:

一些 PyPI 项目在侧边栏中提供了一堆链接,包括更改日志。例如,Django 在 https://pypi.org/project/Django/ 提供这些链接:

如何为我的项目添加更改日志或发布日志的链接?

    标签: python setuptools pypi python-packaging


    【解决方案1】:

    更改日志没有特殊情况。只需将项目链接添加到在线托管的发布日志。

    如果您使用的是setuptools,则可以在setup.py 文件中使用project_urls 关键字参数,如下所示:

    from setuptools import setup
    
    setup(
        name='foobar',
        version='1.0',
        # ...
        project_urls={
            'Documentation': 'https://example.com/documentation/',
            'GitHub': 'https://github.com/foobar/foobar/',
            'Changelog': 'https://github.com/foobar/foobar/blob/master/CHANGELOG.md',
        },
    )
    

    project_urls 关键字参数采用字典将链接标题映射到其 URL。链接标题可以是任何你喜欢的,它们将显示在 PyPI 项目页面上,所以使用英文标签。

    如果您更喜欢使用setup.cfg,可以将这些行添加到您的setup.cfg

    project_urls =
        Documentation = https://example.com/documentation/
        GitHub = https://github.com/foobar/foobar
        Changelog = https://github.com/foobar/foobar/blob/master/CHANGELOG.md
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-09
      • 2015-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 2013-11-09
      相关资源
      最近更新 更多