1. Daniel Holth
  2. wheel

Commits

Daniel Holth  committed 7f311fe

implement pydist.schema rename

  • Participants
  • Parent commits 3263ce2
  • Branches default

Comments (0)

Files changed (7)

File setup.py

View file
-import os, sys, codecs
+import os.path, sys, codecs, re
 
 from setuptools import setup
 
 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:
     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=[

File wheel/__init__.py

View file
-#
+# __variables__ with double-quoted values will be available in setup.py:
+__version__ = "0.19.0"

File wheel/bdist_wheel.py

View file
         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)
 

File wheel/metadata.py

View file
 import textwrap
 import pkg_resources
 import email.parser
+import wheel
 
 METADATA_VERSION = "2.0"
 
     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:
     distribution: optional distutils Distribution()
     """
 
-    metadata = {}
+    metadata = {"generator":"bdist_wheel (" + wheel.__version__ + ")"}
     try:
         unicode
         pkg_info = read_pkg_info(path)
             try:
                 requirements = getattr(distribution, attr)
                 if requirements:
-                    metadata[requires] = [{'install':requirements}]
+                    metadata[requires] = [{'requires':requirements}]
             except AttributeError:
                 pass
 

File wheel/test/pydist-schema.json

View file
+{
+  "id": "http://www.python.org/dev/peps/pep-0426/",
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "title": "Metadata for Python Software Packages 2.0",
+  "type": "object",
+  "properties": {
+    "metadata_version": {
+      "description": "Version of the file format",
+      "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",
+      "$ref": "#/definitions/valid_name"
+    },
+    "version": {
+      "description": "The distribution's public version identifier",
+      "type": "string",
+      "pattern": "^(\\d+(\\.\\d+)*)((a|b|c|rc)(\\d+))?(\\.(post)(\\d+))?(\\.(dev)(\\d+))?$"
+    },
+    "source_label": {
+      "description": "A constrained identifying text string",
+      "type": "string",
+      "pattern": "^[0-9a-z_.-+]+$"
+    },
+    "source_url": {
+      "description": "A string containing a full URL where the source for this specific version of the distribution can be downloaded.",
+      "type": "string",
+      "format": "uri"
+    },
+    "summary": {
+      "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",
+      "items": {
+        "type": "string",
+        "$ref": "#/definitions/extra_name"
+      }
+    },
+    "meta_requires": {
+      "description": "A list of subdistributions made available through this metadistribution.",
+      "type": "array",
+      "$ref": "#/definitions/dependencies"
+    },
+    "run_requires": {
+      "description": "A list of other distributions needed to run this distribution.",
+      "type": "array",
+      "$ref": "#/definitions/dependencies"
+    },
+    "test_requires": {
+      "description": "A list of other distributions needed when this distribution is tested.",
+      "type": "array",
+      "$ref": "#/definitions/dependencies"
+    },
+    "build_requires": {
+      "description": "A list of other distributions needed when this distribution is built.",
+      "type": "array",
+      "$ref": "#/definitions/dependencies"
+    },
+    "dev_requires": {
+      "description": "A list of other distributions needed when this distribution is developed.",
+      "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)",
+      "type": "array",
+      "items": {
+        "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/requirement"
+    },
+    "supports_environments": {
+      "description": "A list of strings specifying the environments that the distribution explicitly supports.",
+      "type": "array",
+      "items": {
+        "type": "string",
+        "$ref": "#/definitions/environment_marker"
+      }
+    },
+    "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.",
+      "type": "object"
+    }
+  },
+
+  "required": ["metadata_version", "name", "version", "summary"],
+  "additionalProperties": false,
+
+  "definitions": {
+    "contact": {
+      "type": "object",
+      "properties": {
+        "name": {
+          "type": "string"
+        },
+        "email": {
+          "type": "string"
+        },
+        "url": {
+          "type": "string"
+        },
+        "role": {
+          "type": "string"
+        }
+      },
+      "required": ["name"],
+      "additionalProperties": false
+    },
+    "dependencies": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "$ref": "#/definitions/dependency"
+      }
+    },
+    "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/requirement"
+          }
+        }
+      },
+      "required": ["requires"],
+      "additionalProperties": false
+    },
+    "valid_name": {
+        "type": "string",
+        "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$"
+    },
+    "requirement": {
+        "type": "string"
+    },
+    "provides_declaration": {
+        "type": "string"
+    },
+    "environment_marker": {
+        "type": "string"
+    },
+    "entry_point": {
+        "type": "string"
+    },
+    "document_name": {
+        "type": "string"
+    },
+    "extra_name" : {
+        "type": "string"
+    }
+  }
+}

File wheel/test/pymeta-schema.json

-{
-  "id": "http://www.python.org/dev/peps/pep-0426/",
-  "$schema": "http://json-schema.org/draft-04/schema#",
-  "title": "Metadata for Python Software Packages 2.0",
-  "type": "object",
-  "properties": {
-    "metadata_version": {
-      "description": "Version of the file format",
-      "type": "string",
-      "pattern": "^(\\d+(\\.\\d+)*)$"
-    },
-    "name": {
-      "description": "The name of the distribution.",
-      "type": "string",
-      "pattern": "^[0-9A-Za-z]([0-9A-Za-z_.-]*[0-9A-Za-z])?$"
-    },
-    "version": {
-      "description": "The distribution's public version identifier",
-      "type": "string",
-      "pattern": "^(\\d+(\\.\\d+)*)((a|b|c|rc)(\\d+))?(\\.(post)(\\d+))?(\\.(dev)(\\d+))?$"
-    },
-    "source_label": {
-      "description": "A constrained identifying text string",
-      "type": "string",
-      "pattern": "^[0-9a-z_.-+]+$"
-    },
-    "source_url": {
-      "description": "A string containing a full URL where the source for this specific version of the distribution can be downloaded.",
-      "type": "string",
-      "format": "uri"
-    },
-    "summary": {
-      "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",
-      "items": {
-        "type": "string",
-        "$ref": "#/definitions/extra_name"
-      }
-    },
-    "distributes": {
-      "description": "A list of subdistributions made available through this metadistribution.",
-      "$ref": "#/definitions/conditional_dependencies"
-    },
-    "run_requires": {
-      "description": "A list of other distributions needed when to run this distribution.",
-      "type": "array",
-      "$ref": "#/definitions/conditional_dependencies"
-    },
-    "test_requires": {
-      "description": "A list of other distributions needed when this distribution is tested.",
-      "$ref": "#/definitions/conditional_dependencies"
-    },
-    "build_requires": {
-      "description": "A list of other distributions needed when this distribution is built.",
-      "$ref": "#/definitions/conditional_dependencies"
-    },
-    "dev_requires": {
-      "description": "A list of other distributions needed when this distribution is developed.",
-      "$ref": "#/definitions/conditional_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.",
-      "type": "array",
-      "items": {
-        "type": "string"
-      }
-    },
-    "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"
-    },
-    "supports_environments": {
-      "description": "A list of strings specifying the environments that the distribution explicitly supports.",
-      "type": "array",
-      "items": {
-        "type": "string",
-        "$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"
-    },
-    "extensions": {
-      "description": "Extensions to the metadata may be present in a mapping under the 'extensions' key.",
-      "type": "object"
-    }
-  },
-
-  "required": ["metadata_version", "name", "version"],
-  "additionalProperties": false,
-
-  "definitions": {
-    "contact": {
-      "type": "object",
-      "properties": {
-        "name": {
-          "type": "string"
-        },
-        "email": {
-          "type": "string"
-        },
-        "url": {
-          "type": "string"
-        },
-        "role": {
-          "type": "string"
-        }
-      },
-      "required": ["name"],
-      "additionalProperties": false
-    },
-    "dependencies": {
-      "type": "array",
-      "items": {
-        "type": "string",
-        "$ref": "#/definitions/version_specifier"
-      }
-    },
-    "conditional_dependencies": {
-      "type": "array",
-      "items": {
-        "type": "object",
-        "properties": {
-          "extra": {
-            "type": "string",
-            "$ref": "#/definitions/extra_name"
-          },
-          "environment": {
-            "type": "string",
-            "$ref": "#/definitions/environment_marker"
-          },
-          "install": {
-            "type": "array",
-            "$ref": "#/definitions/dependencies"
-          }
-        },
-        "required": ["install"],
-        "additionalProperties": false
-      }
-    },
-    "version_specifier": {
-        "type": "string"
-    },
-    "extra_name": {
-        "type": "string"
-    },
-    "environment_marker": {
-        "type": "string"
-    },
-    "document_name": {
-        "type": "string"
-    }
-  }
-}

File wheel/test/test_basic.py

View file
         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
         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)
                 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."""