diff options
author | Daniel Holth <dholth@fastmail.fm> | 2013-07-19 12:02:49 -0400 |
---|---|---|
committer | Daniel Holth <dholth@fastmail.fm> | 2013-07-19 12:02:49 -0400 |
commit | bb2774fe4348e01f0ae840ac06d1574baa874a90 (patch) | |
tree | 5a623d398f5832cc11610c4b408bc4ab717462d0 | |
parent | c191ab2951a7c8e38565e62b58826c8cb25028b4 (diff) | |
download | wheel-bb2774fe4348e01f0ae840ac06d1574baa874a90.tar.gz |
implement pydist.schema rename
-rw-r--r-- | setup.py | 8 | ||||
-rw-r--r-- | wheel/__init__.py | 3 | ||||
-rw-r--r-- | wheel/bdist_wheel.py | 2 | ||||
-rw-r--r-- | wheel/metadata.py | 7 | ||||
-rw-r--r-- | wheel/test/pydist-schema.json (renamed from wheel/test/pymeta-schema.json) | 106 | ||||
-rw-r--r-- | wheel/test/test_basic.py | 10 |
6 files changed, 86 insertions, 50 deletions
@@ -1,4 +1,4 @@ -import os, sys, codecs +import os.path, sys, codecs, re from setuptools import setup @@ -6,6 +6,10 @@ here = os.path.abspath(os.path.dirname(__file__)) README = codecs.open(os.path.join(here, 'README.txt'), encoding='utf8').read() CHANGES = codecs.open(os.path.join(here, 'CHANGES.txt'), encoding='utf8').read() +with codecs.open(os.path.join(os.path.dirname(__file__), 'wheel', '__init__.py'), + encoding='utf8') as version_file: + metadata = dict(re.findall(r"""__([a-z]+)__ = "([^"]+)""", version_file.read())) + # # All these requirements are overridden by setup.cfg when wheel is built # as a wheel: @@ -18,7 +22,7 @@ if sys.version_info[:2] < (2, 7): install_requires.append('argparse') setup(name='wheel', - version='0.18.0', + version=metadata['version'], description='A built-package format for Python.', long_description=README + '\n\n' + CHANGES, classifiers=[ diff --git a/wheel/__init__.py b/wheel/__init__.py index 792d600..5103a27 100644 --- a/wheel/__init__.py +++ b/wheel/__init__.py @@ -1 +1,2 @@ -# +# __variables__ with double-quoted values will be available in setup.py: +__version__ = "0.19.0"
\ No newline at end of file diff --git a/wheel/bdist_wheel.py b/wheel/bdist_wheel.py index 61868f1..39e6166 100644 --- a/wheel/bdist_wheel.py +++ b/wheel/bdist_wheel.py @@ -371,7 +371,7 @@ class bdist_wheel(Command): self.add_requirements(metadata_path) # XXX not a final specification - metadata_json_path = os.path.join(distinfo_path, 'pymeta.json') + metadata_json_path = os.path.join(distinfo_path, 'pydist.json') pymeta = pkginfo_to_dict(metadata_path, distribution=self.distribution) diff --git a/wheel/metadata.py b/wheel/metadata.py index 2a9569e..c0fdd63 100644 --- a/wheel/metadata.py +++ b/wheel/metadata.py @@ -10,6 +10,7 @@ import os import textwrap import pkg_resources import email.parser +import wheel METADATA_VERSION = "2.0" @@ -69,7 +70,7 @@ def handle_requires(metadata, pkg_info, key): if may_requires: metadata['run_requires'] = [] for key, value in may_requires.items(): - may_requirement = {'install':value} + may_requirement = {'requires':value} if key.extra: may_requirement['extra'] = key.extra if key.condition: @@ -92,7 +93,7 @@ def pkginfo_to_dict(path, distribution=None): distribution: optional distutils Distribution() """ - metadata = {} + metadata = {"generator":"bdist_wheel (" + wheel.__version__ + ")"} try: unicode pkg_info = read_pkg_info(path) @@ -156,7 +157,7 @@ def pkginfo_to_dict(path, distribution=None): try: requirements = getattr(distribution, attr) if requirements: - metadata[requires] = [{'install':requirements}] + metadata[requires] = [{'requires':requirements}] except AttributeError: pass diff --git a/wheel/test/pymeta-schema.json b/wheel/test/pydist-schema.json index 0bc659f..41eb64a 100644 --- a/wheel/test/pymeta-schema.json +++ b/wheel/test/pydist-schema.json @@ -9,10 +9,15 @@ "type": "string", "pattern": "^(\\d+(\\.\\d+)*)$" }, + "generator": { + "description": "Name and version of the program that produced this file.", + "type": "string", + "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])( \\(.*\\))?$" + }, "name": { "description": "The name of the distribution.", "type": "string", - "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$" + "$ref": "#/definitions/valid_name" }, "version": { "description": "The distribution's public version identifier", @@ -98,38 +103,43 @@ "$ref": "#/definitions/extra_name" } }, - "distributes": { + "meta_requires": { "description": "A list of subdistributions made available through this metadistribution.", - "$ref": "#/definitions/conditional_dependencies" + "type": "array", + "$ref": "#/definitions/dependencies" }, "run_requires": { - "description": "A list of other distributions needed when to run this distribution.", + "description": "A list of other distributions needed to run this distribution.", "type": "array", - "$ref": "#/definitions/conditional_dependencies" + "$ref": "#/definitions/dependencies" }, "test_requires": { "description": "A list of other distributions needed when this distribution is tested.", - "$ref": "#/definitions/conditional_dependencies" + "type": "array", + "$ref": "#/definitions/dependencies" }, "build_requires": { "description": "A list of other distributions needed when this distribution is built.", - "$ref": "#/definitions/conditional_dependencies" + "type": "array", + "$ref": "#/definitions/dependencies" }, "dev_requires": { "description": "A list of other distributions needed when this distribution is developed.", - "$ref": "#/definitions/conditional_dependencies" + "type": "array", + "$ref": "#/definitions/dependencies" }, "provides": { - "description": "A list of strings naming additional dependency requirements that are satisfied by installing this distribution. These strings must be of the form Name or Name (Version), as for the requires field.", + "description": "A list of strings naming additional dependency requirements that are satisfied by installing this distribution. These strings must be of the form Name or Name (Version)", "type": "array", "items": { - "type": "string" + "type": "string", + "$ref": "#/definitions/provides_declaration" } }, "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", - "$ref": "#/definitions/version_specifier" + "$ref": "#/definitions/requirement" }, "supports_environments": { "description": "A list of strings specifying the environments that the distribution explicitly supports.", @@ -139,9 +149,19 @@ "$ref": "#/definitions/environment_marker" } }, - "metabuild_hooks": { - "description": "The metabuild_hooks field is used to define various operations that may be invoked on a distribution in a platform independent manner.", - "type": "object" + "install_hooks": { + "description": "The install_hooks field is used to define various operations that may be invoked on a distribution in a platform independent manner.", + "type": "object", + "properties": { + "postinstall": { + "type": "string", + "$ref": "#/definitions/entry_point" + }, + "preuninstall": { + "type": "string", + "$ref": "#/definitions/entry_point" + } + } }, "extensions": { "description": "Extensions to the metadata may be present in a mapping under the 'extensions' key.", @@ -149,7 +169,7 @@ } }, - "required": ["metadata_version", "name", "version"], + "required": ["metadata_version", "name", "version", "summary"], "additionalProperties": false, "definitions": { @@ -175,43 +195,53 @@ "dependencies": { "type": "array", "items": { - "type": "string", - "$ref": "#/definitions/version_specifier" + "type": "object", + "$ref": "#/definitions/dependency" } }, - "conditional_dependencies": { - "type": "array", - "items": { - "type": "object", - "properties": { - "extra": { - "type": "string", - "$ref": "#/definitions/extra_name" - }, - "environment": { + "dependency": { + "type": "object", + "properties": { + "extra": { + "type": "string", + "$ref": "#/definitions/valid_name" + }, + "environment": { + "type": "string", + "$ref": "#/definitions/environment_marker" + }, + "requires": { + "type": "array", + "items": { "type": "string", - "$ref": "#/definitions/environment_marker" - }, - "install": { - "type": "array", - "$ref": "#/definitions/dependencies" + "$ref": "#/definitions/requirement" } - }, - "required": ["install"], - "additionalProperties": false - } + } + }, + "required": ["requires"], + "additionalProperties": false + }, + "valid_name": { + "type": "string", + "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$" }, - "version_specifier": { + "requirement": { "type": "string" }, - "extra_name": { + "provides_declaration": { "type": "string" }, "environment_marker": { "type": "string" }, + "entry_point": { + "type": "string" + }, "document_name": { "type": "string" + }, + "extra_name" : { + "type": "string" } } } diff --git a/wheel/test/test_basic.py b/wheel/test/test_basic.py index 4584b0a..0e88c74 100644 --- a/wheel/test/test_basic.py +++ b/wheel/test/test_basic.py @@ -99,8 +99,8 @@ def test_unpack(): for wheelfile in (w for w in os.listdir(distdir) if w.endswith('.whl')): wheel.tool.unpack(os.path.join(distdir, wheelfile), distdir) -def test_pymeta(): - """Make sure pymeta.json exists and validates against our schema.""" +def test_pydist(): + """Make sure pydist.json exists and validates against our schema.""" # XXX this test may need manual cleanup of older wheels import jsonschema @@ -109,7 +109,7 @@ def test_pymeta(): return json.loads(open(filename, 'rb').read().decode('utf-8')) pymeta_schema = open_json(resource_filename('wheel.test', - 'pymeta-schema.json')) + 'pydist-schema.json')) valid = 0 for dist in ("simple.dist", "complex-dist"): basedir = pkg_resources.resource_filename('wheel.test', dist) @@ -118,11 +118,11 @@ def test_pymeta(): if filename.endswith('.whl'): whl = ZipFile(os.path.join(dirname, filename)) for entry in whl.infolist(): - if entry.filename.endswith('/pymeta.json'): + if entry.filename.endswith('/pydist.json'): pymeta = json.loads(whl.read(entry).decode('utf-8')) jsonschema.validate(pymeta, pymeta_schema) valid += 1 - assert valid > 0, "No pymeta.json found" + assert valid > 0, "No pydist.json found" def test_util(): """Test functions in util.py.""" |