diff options
author | Daniel Holth <dholth@fastmail.fm> | 2013-06-01 23:20:04 -0400 |
---|---|---|
committer | Daniel Holth <dholth@fastmail.fm> | 2013-06-01 23:20:04 -0400 |
commit | 79532459fc5a840ab3cf57ecb162199e493f95ff (patch) | |
tree | ac3a57b154b978f77e81216217a769b9046f8fe8 | |
parent | bdcb1e73574c73fd5a2dced50eb5553cb56e4548 (diff) | |
download | wheel-79532459fc5a840ab3cf57ecb162199e493f95ff.tar.gz |
disallow extra keys in pymeta.json; handle home page, author
-rw-r--r-- | wheel/metadata.py | 34 | ||||
-rw-r--r-- | wheel/test/complex-dist/setup.py | 3 | ||||
-rw-r--r-- | wheel/test/pymeta-schema.json | 7 |
3 files changed, 41 insertions, 3 deletions
diff --git a/wheel/metadata.py b/wheel/metadata.py index 4315b72..518f762 100644 --- a/wheel/metadata.py +++ b/wheel/metadata.py @@ -5,11 +5,22 @@ from .pkginfo import read_pkg_info import re METADATA_VERSION = "2.0" + PLURAL_FIELDS = { "classifier" : "classifiers", "provides_dist" : "provides", "provides_extra" : "extras" } + SKIP_FIELDS = set() +CONTACT_FIELDS = (({"email":"author_email", "name": "author"}, + "author"), + ({"email":"maintainer_email", "name": "maintainer"}, + "maintainer")) + +# commonly filled out as "UNKNOWN" by distutils: +UNKNOWN_FIELDS = set(("author", "author_email", "platform", "home_page", + "license")) + # Will only support markers-as-extras here. Wheel itself is probably # the only program that uses non-extras markers in METADATA/PKG-INFO. EXTRA_RE = re.compile("extra == '(?P<extra>.+)'") @@ -37,6 +48,9 @@ def pkginfo_to_dict(path, distribution=None): if low_key in SKIP_FIELDS: continue + + if low_key in UNKNOWN_FIELDS and pkg_info.get(key) == 'UNKNOWN': + continue if low_key in PLURAL_FIELDS: metadata[PLURAL_FIELDS[low_key]] = pkg_info.get_all(key) @@ -60,16 +74,21 @@ def pkginfo_to_dict(path, distribution=None): for key, value in sorted(extra_requirements.items())] metadata['extras'] = [key for key in sorted(extra_requirements.keys())] - elif low_key == 'provides-extra': + elif low_key == 'provides_extra': if not 'extras' in metadata: metadata['extras'] = [] metadata['extras'].extend(pkg_info.get_all(key)) + + + elif low_key == 'home_page': + metadata['project_urls'] = [{'Home':pkg_info[key]}] else: metadata[low_key] = pkg_info[key] metadata['metadata_version'] = METADATA_VERSION + # include extra information if distribution is available if distribution: for requires, attr in (('test_requires', 'tests_require'),): try: @@ -79,6 +98,19 @@ def pkginfo_to_dict(path, distribution=None): except AttributeError: pass + # handle contacts + contacts = [] + for contact_type, role in CONTACT_FIELDS: + contact = {} + for key in contact_type: + if contact_type[key] in metadata: + contact[key] = metadata.pop(contact_type[key]) + if contact: + contact['role'] = role + contacts.append(contact) + if contacts: + metadata['contacts'] = contacts + return metadata if __name__ == "__main__": diff --git a/wheel/test/complex-dist/setup.py b/wheel/test/complex-dist/setup.py index c6855c5..ace0856 100644 --- a/wheel/test/complex-dist/setup.py +++ b/wheel/test/complex-dist/setup.py @@ -11,6 +11,9 @@ except NameError: setup(name='complex-dist', version='0.1', description=u8('Another testing distribution \N{SNOWMAN}'), + author="Illustrious Author", + author_email="illustrious@example.org", + url="http://example.org/exemplary", packages=['complexdist'], setup_requires=["wheel", "setuptools"], install_requires=["quux", "splort"], diff --git a/wheel/test/pymeta-schema.json b/wheel/test/pymeta-schema.json index a7c0d2b..c0bfffe 100644 --- a/wheel/test/pymeta-schema.json +++ b/wheel/test/pymeta-schema.json @@ -134,6 +134,7 @@ }, "required": ["metadata_version", "name", "version"], + "additionalProperties": false, "definitions": { "contact": { @@ -151,7 +152,8 @@ "role": { "type": "string" } - } + }, + "additionalProperties": false }, "may_requires": { "type": "array", @@ -171,7 +173,8 @@ } } }, - "required": ["dependencies"] + "required": ["dependencies"], + "additionalProperties": false } } } |