This creates a wrapper function for writing fields in the PKG-INFO file,
both to simplify the syntax and to add a point where we can inject an
encoding function in order to support Python 2.7 compatibility.
This turns get_metadata_version into a method on DistributionMetadata,
populated either by inferrence (in the case of package metadata
specified in `setup`) or from the data in a specified PKG-INFO file.
To populate metadata_version from PKG-INFO, we need to monkey patch
read_pkg_file in addition to write_pkg_file.
`DeprecationWarning` is not visible by default in the latest versions of
CPython, so this switches the deprecation warnings in setuptools and
pkg_resources over to custom classes derived from `Warning` instead.
Fixes issue github issue #159
Co-authored-by: Junhan Huang <robin.j.huang@gmail.com>
Co-authored-by: Marton Pono <marci93@gmail.com>
Some tools, such as PBR, might want to set
long_description_content_type during the parent object's
Distribution.__init__() call (during distutils setup_keywords entry
points). However, that field is currently unconditionally overwritten
after these calls, erasing the value.
We would rather not duplicate the existing method of copying into
dist.metadata as done with project_urls.
This preserves the fields within Distribution.metadata described by
self._DISTUTIULS_UNUPPORTED_METADATA, or otherwise takes it from
arguments.
A test case that simulates setting the long description and overriding
the arguments is added.
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
Support the same mechanism as for Python sources for declaring
the encoding to be used when reading `setup.cfg` (see PEP 263),
and return the results of reading it as Unicode.
Fix#1062 and #1136.