How to specific metadata version in setup.py?
My package's PKG-INFO defaults to 1.0 metadata version. I tried searching http://docs.python.org/distutils/ to know how to specify 1.2 as the metadata version (so I can include Classifiers[1], maintainer* fields in it), but couldn't find any. Does anyone know? Shouldn't this be documented in http://docs.python.org/distutils/setupscript.html which talks about these additional fields in section 2.8? -srid [1] Evidently, some packages in PyPI do not have 'Classifiers' in their metadata (PKG-INFO) despite specifying it in the setup.py.
On Fri, Mar 19, 2010 at 5:10 PM, Sridhar Ratnakumar
My package's PKG-INFO defaults to 1.0 metadata version. I tried searching http://docs.python.org/distutils/ to know how to specify 1.2 as the metadata version (so I can include Classifiers[1], maintainer* fields in it), but couldn't find any. Does anyone know? Shouldn't this be documented in http://docs.python.org/distutils/setupscript.html which talks about these additional fields in section 2.8? -srid [1] Evidently, some packages in PyPI do not have 'Classifiers' in their metadata (PKG-INFO) despite specifying it in the setup.py.
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) IOW, if you use a PEP 314 field, the DistributionMetadata object should switch to 1.1. ALthough, my advice would be to use the new DistributionMetadata class I have created in distutils2. It's a standalone, PEP 345-compatible class you can use in your own project. It has a micro-interpreter for the environment markers described in PEP 345, and also knows how to read or write 1.1, 1.0 PKG-INFO files. http://hg.python.org/distutils2/file/tip/src/distutils2/metadata.py Feedback and contributions are welcome Tarek
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
-- Tarek Ziadé | http://ziade.org
On Fri, Mar 19, 2010 at 5:22 PM, Tarek Ziadé
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. 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. Tarek -- Tarek Ziadé | http://ziade.org
On 2010-03-19, at 2:27 PM, Tarek Ziadé wrote:
On Fri, Mar 19, 2010 at 5:22 PM, Tarek Ziadé
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
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? -srid [1] http://www.python.org/dev/peps/pep-0301/#distutils-trove-classification
On Fri, Mar 19, 2010 at 5:35 PM, Sridhar Ratnakumar
[..] 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
Why do you force 1.2 here ? There's no tool out there that understand PEP 345 / 1.2 yet. At this time, I'd encourage you to put 1.1 here unless you use PEP 345 fields.
Wasn't PEP 345 fully implemented for distutils1? Ah, I see that it is still "Draft" mode.
I'll switch it to Accepted now. But PEP 345 will not be implemented in Distutils, which is now feature frozen.
Can I use distutils2 to parse PKG-INFO (as a replacement for the `pkginfo` project)?
Yes you can.
Will it read all the fields despite the inaccurate Metadata-Version field?
Yes, it should work. Description fields (==long_description) containing empty lines will stay broken though, because they can't be read back. That's fixed in PEP 345 / 1.2 Regards Tarek -- Tarek Ziadé | http://ziade.org
On 2010-03-19, at 2:51 PM, Tarek Ziadé wrote:
On Fri, Mar 19, 2010 at 5:35 PM, Sridhar Ratnakumar
wrote: [..] 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
Why do you force 1.2 here ?
From http://pypi.python.org/pypi/pkginfo "Added support for the different metadata versions specified in PEPs 241, 314, and 345. Distributions now parse and expose only the attributes corresponding to their metadata version, which defaults to the version parsed from the PKG-INFO file. The programmer can override that version when creating the distribution object." I could as well use 1.1.
There's no tool out there that understand PEP 345 / 1.2 yet.
Apparently pkginfo supports PEP 345 (see above).
At this time, I'd encourage you to put 1.1 here unless you use PEP 345 fields.
Ok. -srid
On Sat, Mar 20, 2010 at 3:33 AM, Sridhar Ratnakumar
There's no tool out there that understand PEP 345 / 1.2 yet.
Apparently pkginfo supports PEP 345 (see above).
It's an old version of PEP 345. It misses for example: - Project-Url - environment markers I think Tres added PEP 345 support a while ago, and it needs an upgrade Regards, Tarek -- Tarek Ziadé | http://ziade.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sridhar Ratnakumar wrote:
On 2010-03-19, at 2:27 PM, Tarek Ziadé 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
On Fri, Mar 19, 2010 at 5:22 PM, Tarek Ziadé
wrote: [..] 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@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-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tarek Ziadé wrote:
On Sat, Mar 20, 2010 at 3:33 AM, Sridhar Ratnakumar
wrote: [..] There's no tool out there that understand PEP 345 / 1.2 yet.
Apparently pkginfo supports PEP 345 (see above).
It's an old version of PEP 345. It misses for example:
- Project-Url - environment markers
I think Tres added PEP 345 support a while ago, and it needs an upgrade
I'm happy to take patches which add support for parsing the extra fields and environment syntac, but given that no tools are *emitting* them yet, I'm not likely to get around to adding them myself for a bit. $ bzr co lp:~tseaver/pkginfo/trunk :) Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@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 iEYEARECAAYFAkuk+lcACgkQ+gerLs4ltQ6HZQCdF7471zHdY26GLh01CiiTjr1+ Nu0AoMToWoWKW1Jd0nQx+YEfVdsPDhkp =fwhE -----END PGP SIGNATURE-----
Ah OK. I misunderstood (was thinking that env markets and prj url were added to another PEP). -srid On 2010-03-20, at 6:39 AM, Tarek Ziadé wrote:
On Sat, Mar 20, 2010 at 3:33 AM, Sridhar Ratnakumar
wrote: [..] There's no tool out there that understand PEP 345 / 1.2 yet.
Apparently pkginfo supports PEP 345 (see above).
It's an old version of PEP 345. It misses for example:
- Project-Url - environment markers
I think Tres added PEP 345 support a while ago, and it needs an upgrade
Regards, Tarek -- Tarek Ziadé | http://ziade.org
On Sat, Mar 20, 2010 at 12:39 PM, Tres Seaver
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Tarek Ziadé wrote:
On Sat, Mar 20, 2010 at 3:33 AM, Sridhar Ratnakumar
wrote: [..] There's no tool out there that understand PEP 345 / 1.2 yet.
Apparently pkginfo supports PEP 345 (see above).
It's an old version of PEP 345. It misses for example:
- Project-Url - environment markers
I think Tres added PEP 345 support a while ago, and it needs an upgrade
I'm happy to take patches which add support for parsing the extra fields and environment syntac, but given that no tools are *emitting* them yet, I'm not likely to get around to adding them myself for a bit.
$ bzr co lp:~tseaver/pkginfo/trunk
:)
I am planning to release a first alpha of distutils2 sometimes in April, as soon as I have finished the implementation on PyPI side, so it can accept these new fields. So that will be the first tool that emit them. Next, I think the pkginfo project is very close to the new DistutilsMetadata class in distutils2 : it write *and* reads the PKG-INFO file, so I am more likely to focus on the distutils2 implementation at this point. Regards, Tarek -- Tarek Ziadé | http://ziade.org
participants (3)
-
Sridhar Ratnakumar
-
Tarek Ziadé
-
Tres Seaver