diff options
| author | Jeremy Stanley <fungi@yuggoth.org> | 2017-11-21 00:48:44 +0000 |
|---|---|---|
| committer | Jeremy Stanley <fungi@yuggoth.org> | 2017-11-22 19:24:12 +0000 |
| commit | df2246449c271c07586bcecc3eaa36e9b0e94e3d (patch) | |
| tree | a729506809366de107bf68d4d9962cd043dc0e93 /setuptools/dist.py | |
| parent | d45be2cc4f7a1e4ddc70b363baaa613c6b068b98 (diff) | |
| download | python-setuptools-git-df2246449c271c07586bcecc3eaa36e9b0e94e3d.tar.gz | |
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 and setup.py 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
Diffstat (limited to 'setuptools/dist.py')
| -rw-r--r-- | setuptools/dist.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py index aa304500..fa03cd27 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -44,7 +44,7 @@ def write_pkg_file(self, file): self.classifiers or self.download_url): version = '1.1' # Setuptools specific for PEP 345 - if hasattr(self, 'python_requires'): + if hasattr(self, 'python_requires') or self.project_urls: version = '1.2' file.write('Metadata-Version: %s\n' % version) @@ -57,6 +57,8 @@ def write_pkg_file(self, file): file.write('License: %s\n' % self.get_license()) if self.download_url: file.write('Download-URL: %s\n' % self.download_url) + for project_url in self.project_urls.items(): + file.write('Project-URL: %s, %s\n' % project_url) long_desc_content_type = getattr( self, @@ -327,11 +329,18 @@ class Distribution(Distribution_parse_config_files, _Distribution): self.long_description_content_type = attrs.get( 'long_description_content_type' ) + self.project_urls = attrs.get('project_urls', {}) self.dependency_links = attrs.pop('dependency_links', []) self.setup_requires = attrs.pop('setup_requires', []) for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'): vars(self).setdefault(ep.name, None) _Distribution.__init__(self, attrs) + + # The project_urls attribute may not be supported in distutils, so + # prime it here from our value if not automatically set + self.metadata.project_urls = getattr( + self.metadata, 'project_urls', self.project_urls) + if isinstance(self.metadata.version, numbers.Number): # Some people apparently take "version number" too literally :) self.metadata.version = str(self.metadata.version) |
