[Distutils] Updated drafts of metadata 2.0 (PEP 426 and PEP 440)

Vinay Sajip vinay_sajip at yahoo.co.uk
Sun Jun 23 19:52:13 CEST 2013


Nick Coghlan <ncoghlan <at> gmail.com> writes:

> * References wheel and warehouse from legacy metadata appendix

It may also be worth mentioning that:

* distlib supports converting legacy metadata to the new format; it's as
  simple as:

  from distlib.metadata import Metadata
  metadata = Metadata(path='PKG-INFO')
  metadata.write(path='pymeta.json')

* Metadata extracted from setup.py, which includes full dependency
  information, is available through distlib's locate function. This
  includes setuptools' newest format for extras, which has support for
  for environment markers. For example:

  from distlib.locators import locate
  dist = locate('setuptools')
  dist.metadata.write('pymeta.json')

  Then pymeta.json contains (some fields omitted for brevity, but the
  dependency stuff is there):

  {
    "version": "0.7.4", 
    "name": "setuptools", 
    "metadata_version": "2.0", 
    "run_may_require": [
      {
        "environment": "sys_platform=='win32'", 
        "dependencies": [
          "wincertstore (== 0.1)"
        ], 
        "extra": "ssl"
      }, 
      {
        "environment": "sys_platform=='win32' and python_version=='2.4'", 
        "dependencies": [
          "ctypes (== 1.0.2)"
        ], 
        "extra": "ssl"
      }, 
      {
        "dependencies": [
          "certifi (== 0.0.8)"
        ], 
        "extra": "certs"
      }, 
      {
        "environment": "python_version in '2.4, 2.5'", 
        "dependencies": [
          "ssl (== 1.16)"
        ], 
        "extra": "ssl"
      }
    ], 
    "extras": [
      "certs", 
      "ssl"
    ], 
  }

I would welcome feedback from anyone who cares to clone/sync the distlib
repository. A release of distlib with this functionality will occur once 
incorporation of the latest spec changes occurs, and I'm comfortable that
distlib is reasonably stable following these changes. Additional testing by
others can speed up getting to that point :-)

Regards,

Vinay Sajip



More information about the Distutils-SIG mailing list