[Distutils] How to specific metadata version in setup.py?
Tres Seaver
tseaver at palladion.com
Sat Mar 20 17:36:07 CET 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Sridhar Ratnakumar wrote:
> On 2010-03-19, at 2:27 PM, Tarek Ziadé wrote:
>
>> On Fri, Mar 19, 2010 at 5:22 PM, Tarek Ziadé <ziade.tarek at gmail.com> wrote:
>> [..]
>>> You can't do it, distutils will automatically set 1.0 or 1.1 depending
>>> on the options you have used. (and not 1.2)
>> Re-reading the current distutils (1) code, I realize that it'll switch
>> to 1.1 *only* if you have used
>> provides, requires or obsolete, so it's partially implemented.
>
> Ok. As a result of this, PKG-INFO that contains the "Classifiers"
> fields still has 1.0 as Metadata-Version. Consequently,
> http://pypi.python.org/pypi/pkginfo fails to read extra metadata fields.
> If Tres is reading this, I had to do the following hack as a workaroud:
>
> from pkginfo import Distribution
>
> class PkgInfoFile(Distribution):
> # Not all packages' PKG-INFO define the proper metadata
> # For eg., modern-package-template uses the Classifiers field and yet
> # uses 1.0 as the metadata version (Classifiers is only defined in 1.1)
> metadata_version = '1.2' # not all PKG-INFO file have proper metadata version
If you know you want to parse '1.2' fields regardless of the version in
the PKG-INFO file, then set the 'metadata_version' attribute on the
Distribution instance before calling 'parse'. E.g.::
from pkginfo import Distribution
d = Distribution()
d.metadata_version = '1.2'
d.parse(open('/path/to/PKG-INFO').read())
The concrete classes (SDist, BDist, Develop, Installed) all take
'metadata_version' as a constructor argument, just to provide for this
case. I'm not sure why you would define a PkgInfo class, actually: it
needs to have a 'read' method, at least, to allow the usual operation
('extractMetadata') to work. I think your usecase is probably covered
by either the Installed or Develop classes. If you do have a usedase,
the public bzr branch is here:
lp:~tseaver/pkginfo/trunk
I'll be glad to review and merge a patch which adds your support, and
make a new release.
>> The new class is much cleaner in the implementation, and so is the
>> register command for PyPI.
>>
>> Notice that we have almost finished the implementation of PEP 345 on
>> PyPI side so we will soon be able to push PEP 345 fields over there.
>
> Wasn't PEP 345 fully implemented for distutils1? Ah, I see that it is
> still "Draft" mode.
>
> Can I use distutils2 to parse PKG-INFO (as a replacement for the
> `pkginfo` project)? Will it read all the fields despite the
> inaccurate Metadata-Version field?
I haven't looked at 'distutils2' yet.
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEUEARECAAYFAkuk+XIACgkQ+gerLs4ltQ71HACfQI8VKM7jKsaQ+jyPHoY/e7vF
/jMAl0Gls9B1+kFFojjcOpRwOpFufCs=
=ZQgL
-----END PGP SIGNATURE-----
More information about the Distutils-SIG
mailing list