summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Holth <dholth@fastmail.fm>2014-04-10 22:24:47 -0400
committerDaniel Holth <dholth@fastmail.fm>2014-04-10 22:24:47 -0400
commit4e90d3b5ec2c0e0ded8ca42416f1dad93aa7e8ab (patch)
tree52685b07a84cc2ba7c121f5ec36df6bd214e3e24
parenta06cd5a1b84c9f3b7b6637b318643dca0a5caad6 (diff)
downloadwheel-4e90d3b5ec2c0e0ded8ca42416f1dad93aa7e8ab.tar.gz
update json metadata generation
-rw-r--r--setup.py4
-rw-r--r--wheel/bdist_wheel.py6
-rw-r--r--wheel/metadata.py20
-rw-r--r--wheel/test/pydist-schema.json195
4 files changed, 124 insertions, 101 deletions
diff --git a/setup.py b/setup.py
index 2128e1f..a055a0b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-import os.path, sys, codecs, re
+import os.path, codecs, re
from setuptools import setup
@@ -28,7 +28,7 @@ setup(name='wheel',
],
author='Daniel Holth',
author_email='dholth@fastmail.fm',
- url='http://bitbucket.org/dholth/wheel/',
+ url='http://bitbucket.org/pypa/wheel/',
keywords=['wheel', 'packaging'],
license='MIT',
packages=[
diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py
index 37ebfae..df3575c 100644
--- a/wheel/bdist_wheel.py
+++ b/wheel/bdist_wheel.py
@@ -399,16 +399,14 @@ class bdist_wheel(Command):
description_filename)
with open(description_path, "wb") as description_file:
description_file.write(description_text.encode('utf-8'))
- pymeta['document_names'] = pymeta.get('document_names', {})
- pymeta['document_names']['description'] = description_filename
+ pymeta['extensions']['python.details']['document_names']['description'] = description_filename
# XXX heuristically copy any LICENSE/LICENSE.txt?
license = self.license_file()
if license:
license_filename = 'LICENSE.txt'
shutil.copy(license, os.path.join(self.distinfo_dir, license_filename))
- pymeta['document_names'] = pymeta.get('document_names', {})
- pymeta['document_names']['license'] = license_filename
+ pymeta['extensions']['python.details']['document_names']['license'] = license_filename
with open(metadata_json_path, "w") as metadata_json:
json.dump(pymeta, metadata_json)
diff --git a/wheel/metadata.py b/wheel/metadata.py
index c582537..b2318d4 100644
--- a/wheel/metadata.py
+++ b/wheel/metadata.py
@@ -93,7 +93,8 @@ def pkginfo_to_dict(path, distribution=None):
distribution: optional distutils Distribution()
"""
- metadata = {"generator":"bdist_wheel (" + wheel.__version__ + ")"}
+ metadata = defaultdict(lambda: defaultdict(lambda: defaultdict(dict)))
+ metadata["generator"] = "bdist_wheel (" + wheel.__version__ + ")"
try:
unicode
pkg_info = read_pkg_info(path)
@@ -141,7 +142,10 @@ def pkginfo_to_dict(path, distribution=None):
metadata['extras'].extend(pkg_info.get_all(key))
elif low_key == 'home_page':
- metadata['project_urls'] = {'Home':pkg_info[key]}
+ metadata['extensions']['python.details']['project_urls'] = {'Home':pkg_info[key]}
+
+ elif low_key == 'keywords':
+ metadata['keywords'] = KEYWORDS_RE.split(pkg_info[key])
else:
metadata[low_key] = pkg_info[key]
@@ -173,7 +177,7 @@ def pkginfo_to_dict(path, distribution=None):
contact['role'] = role
contacts.append(contact)
if contacts:
- metadata['contacts'] = contacts
+ metadata['extensions']['python.details']['contacts'] = contacts
# convert entry points to exports
try:
@@ -186,17 +190,17 @@ def pkginfo_to_dict(path, distribution=None):
name, export = str(item).split(' = ', 1)
exports[group][name] = export
if exports:
- metadata['exports'] = exports
+ metadata['extensions']['python.exports'] = exports
except IOError:
pass
# copy console_scripts entry points to commands
- if 'exports' in metadata:
+ if 'python.exports' in metadata['extensions']:
for (ep_script, wrap_script) in (('console_scripts', 'wrap_console'),
('gui_scripts', 'wrap_gui')):
- if ep_script in metadata['exports']:
- metadata['commands'] = metadata.get('commands', {})
- metadata['commands'][wrap_script] = metadata['exports'][ep_script]
+ if ep_script in metadata['extensions']['python.exports']:
+ metadata['extensions']['python.commands'][wrap_script] = \
+ metadata['extensions']['python.exports'][ep_script]
return metadata
diff --git a/wheel/test/pydist-schema.json b/wheel/test/pydist-schema.json
index fc350bf..566f3a4 100644
--- a/wheel/test/pydist-schema.json
+++ b/wheel/test/pydist-schema.json
@@ -38,63 +38,6 @@
"description": "A one-line summary of what the distribution does.",
"type": "string"
},
- "document_names": {
- "description": "Names of supporting metadata documents",
- "type": "object",
- "properties": {
- "description": {
- "type": "string",
- "$ref": "#/definitions/document_name"
- },
- "changelog": {
- "type": "string",
- "$ref": "#/definitions/document_name"
- },
- "license": {
- "type": "string",
- "$ref": "#/definitions/document_name"
- }
- },
- "additionalProperties": false
- },
- "keywords": {
- "description": "A list of additional keywords to be used to assist searching for the distribution in a larger catalog.",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "license": {
- "description": "A string indicating the license covering the distribution.",
- "type": "string"
- },
- "classifiers": {
- "description": "A list of strings, with each giving a single classification value for the distribution.",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "contacts": {
- "description": "A list of contributor entries giving the recommended contact points for getting more information about the project.",
- "type": "array",
- "items": {
- "type": "object",
- "$ref": "#/definitions/contact"
- }
- },
- "contributors": {
- "description": "A list of contributor entries for other contributors not already listed as current project points of contact.",
- "type": "array",
- "items": {
- "type": "object",
- "$ref": "#/definitions/contact"
- }
- },
- "project_urls": {
- "description": "A mapping of arbitrary text labels to additional URLs relevant to the project.",
- "type": "object"
- },
"extras": {
"description": "A list of optional sets of dependencies that may be used to define conditional dependencies in \"may_require\" and similar fields.",
"type": "array",
@@ -152,16 +95,6 @@
"$ref": "#/definitions/qualified_name"
}
},
- "commands": {
- "description": "Command line interfaces provided by this distribution",
- "type": "object",
- "$ref": "#/definitions/commands"
- },
- "exports": {
- "description": "Other exported interfaces provided by this distribution",
- "type": "object",
- "$ref": "#/definitions/exports"
- },
"obsoleted_by": {
"description": "A string that indicates that this project is no longer being developed. The named project provides a substitute or replacement.",
"type": "string",
@@ -248,6 +181,76 @@
"required": ["requires"],
"additionalProperties": false
},
+ "extensions": {
+ "type": "object",
+ "patternProperties": {
+ "^[A-Za-z][0-9A-Za-z_]*([.][0-9A-Za-z_]*)*$": {}
+ },
+ "properties": {
+ "python.details" : {
+ "description": "More information regarding the distribution.",
+ "type": "object",
+ "properties": {
+ "document_names": {
+ "description": "Names of supporting metadata documents",
+ "type": "object",
+ "properties": {
+ "description": {
+ "type": "string",
+ "$ref": "#/definitions/document_name"
+ },
+ "changelog": {
+ "type": "string",
+ "$ref": "#/definitions/document_name"
+ },
+ "license": {
+ "type": "string",
+ "$ref": "#/definitions/document_name"
+ }
+ },
+ "additionalProperties": false
+ },
+ "keywords": {
+ "description": "A list of additional keywords to be used to assist searching for the distribution in a larger catalog.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "license": {
+ "description": "A string indicating the license covering the distribution.",
+ "type": "string"
+ },
+ "classifiers": {
+ "description": "A list of strings, with each giving a single classification value for the distribution.",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "python.project" : {
+ "description": "More information regarding the creation and maintenance of the distribution.",
+ "$ref": "#/definitions/project_or_integrator"
+ },
+ "python.integrator" : {
+ "description": "More information regarding the downstream redistributor of the distribution.",
+ "$ref": "#/definitions/project_or_integrator"
+ },
+ "python.commands" : {
+ "description": "Command line interfaces provided by this distribution",
+ "type": "object",
+ "$ref": "#/definitions/commands"
+ },
+ "python.exports" : {
+ "description": "Other exported interfaces provided by this distribution",
+ "type": "object",
+ "$ref": "#/definitions/exports"
+ }
+ },
+ "additionalProperties": false
+ },
"commands": {
"type": "object",
"properties": {
@@ -285,13 +288,6 @@
},
"additionalProperties": false
},
- "extensions": {
- "type": "object",
- "patternProperties": {
- "^[A-Za-z][0-9A-Za-z_]*([.][0-9A-Za-z_]*)*$": {}
- },
- "additionalProperties": false
- },
"command_map": {
"type": "object",
"patternProperties": {
@@ -302,40 +298,65 @@
},
"additionalProperties": false
},
+ "project_or_integrator" : {
+ "type": "object",
+ "properties" : {
+ "contacts": {
+ "description": "A list of contributor entries giving the recommended contact points for getting more information about the project.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "$ref": "#/definitions/contact"
+ }
+ },
+ "contributors": {
+ "description": "A list of contributor entries for other contributors not already listed as current project points of contact.",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "$ref": "#/definitions/contact"
+ }
+ },
+ "project_urls": {
+ "description": "A mapping of arbitrary text labels to additional URLs relevant to the project.",
+ "type": "object"
+ }
+ }
+ },
"distribution_name": {
- "type": "string",
- "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$"
+ "type": "string",
+ "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$"
},
"requirement": {
- "type": "string"
+ "type": "string"
},
"provides_declaration": {
- "type": "string"
+ "type": "string"
},
"environment_marker": {
- "type": "string"
+ "type": "string"
},
"document_name": {
- "type": "string"
+ "type": "string"
},
"extra_name" : {
- "type": "string",
- "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$"
+ "type": "string",
+ "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$"
},
"relative_path" : {
- "type": "string"
+ "type": "string"
},
"export_specifier": {
"type": "string",
"pattern": "^([A-Za-z_][A-Za-z_0-9]*([.][A-Za-z_][A-Za-z_0-9]*)*)(:[A-Za-z_][A-Za-z_0-9]*([.][A-Za-z_][A-Za-z_0-9]*)*)?(\\[[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?\\])?$"
},
"qualified_name" : {
- "type": "string",
- "pattern": "^[A-Za-z_][A-Za-z_0-9]*([.][A-Za-z_][A-Za-z_0-9]*)*$"
+ "type": "string",
+ "pattern": "^[A-Za-z_][A-Za-z_0-9]*([.][A-Za-z_][A-Za-z_0-9]*)*$"
},
"prefixed_name" : {
- "type": "string",
- "pattern": "^[A-Za-z_][A-Za-z_0-9]*([.][A-Za-z_0-9]*)*$"
+ "type": "string",
+ "pattern": "^[A-Za-z_][A-Za-z_0-9]*([.][A-Za-z_0-9]*)*$"
}
}
}