From 839ef3428d909e3b198a58029147d3d834c540d8 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 20 Nov 2017 18:04:26 +0000 Subject: [PATCH] Support PEP 345 Project-URL metadata By including one or more Project-URL entries in PKG-INFO metadata, PyPI can display helpful hyperlinks in a generic manner. Add support here to be able to pass it through setup.cfg with a project_urls dict. See the corresponding section of the Core Metadata Specifications from the Python Packaging User Guide for details: https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use Setuptools implementation is underway here: https://github.com/pypa/setuptools/pull/1210 Change-Id: I14e580c654b619cab7eb24e31f736056d6cf9bd4 --- doc/source/user/using.rst | 4 ++++ pbr/tests/testpackage/setup.cfg | 4 ++++ pbr/util.py | 10 ++++++++++ setup.cfg | 4 ++++ 4 files changed, 22 insertions(+) diff --git a/doc/source/user/using.rst b/doc/source/user/using.rst index 4b08ec4e..e22dc548 100644 --- a/doc/source/user/using.rst +++ b/doc/source/user/using.rst @@ -52,6 +52,10 @@ itself): summary = OpenStack's setup automation in a reusable form description-file = README home-page = https://launchpad.net/pbr + project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/ + Documentation = https://docs.openstack.org/pbr/ + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/ license = Apache-2 classifier = Development Status :: 4 - Beta diff --git a/pbr/tests/testpackage/setup.cfg b/pbr/tests/testpackage/setup.cfg index d10a87e9..d0d899b4 100644 --- a/pbr/tests/testpackage/setup.cfg +++ b/pbr/tests/testpackage/setup.cfg @@ -6,6 +6,10 @@ version = 0.1.dev author = OpenStack author-email = openstack-dev@lists.openstack.org home-page = http://pypi.python.org/pypi/pbr +project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/ + Documentation = https://docs.openstack.org/pbr/ + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/ summary = Test package for testing pbr description-file = README.txt diff --git a/pbr/util.py b/pbr/util.py index dc8995ea..b6c12d73 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -101,6 +101,7 @@ D1_D2_SETUP_ARGS = { "maintainer": ("metadata",), "maintainer_email": ("metadata",), "url": ("metadata", "home_page"), + "project_urls": ("metadata",), "description": ("metadata", "summary"), "keywords": ("metadata",), "long_description": ("metadata", "description"), @@ -148,6 +149,9 @@ MULTI_FIELDS = ("classifiers", "tests_require", "cmdclass") +# setup() arguments that can have mapping values in setup.cfg +MAP_FIELDS = ("project_urls",) + # setup() arguments that contain boolean values BOOL_FIELDS = ("use_2to3", "zip_safe", "include_package_data") @@ -321,6 +325,12 @@ def setup_cfg_to_setup_kwargs(config, script_args=()): in_cfg_value = split_csv(in_cfg_value) if arg in MULTI_FIELDS: in_cfg_value = split_multiline(in_cfg_value) + elif arg in MAP_FIELDS: + in_cfg_map = {} + for i in split_multiline(in_cfg_value): + k, v = i.split('=') + in_cfg_map[k.strip()] = v.strip() + in_cfg_value = in_cfg_map elif arg in BOOL_FIELDS: # Provide some flexibility here... if in_cfg_value.lower() in ('true', 't', '1', 'yes', 'y'): diff --git a/setup.cfg b/setup.cfg index 35f0d729..be8cfd43 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,6 +6,10 @@ summary = Python Build Reasonableness description-file = README.rst home-page = https://docs.openstack.org/pbr/latest/ +project_urls = + Bug Tracker = https://bugs.launchpad.net/pbr/ + Documentation = https://docs.openstack.org/pbr/ + Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/ requires-python = >=2.6 classifier = Development Status :: 5 - Production/Stable