This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implement pkgutil APIs as described in PEP 376
Type: enhancement Stage: resolved
Components: Distutils2 Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tarek Nosy List: aalbrecht, alexis, eric.araujo, flub, meatballhat, rayterrill, tarek
Priority: normal Keywords: patch

Created on 2009-01-10 17:45 by tarek, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
get_metadata.diff tarek, 2009-01-14 21:02
Messages (14)
msg79562 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-01-10 17:45
Let's add a "get_metadata" API in Distutils that would return
in a dictionary the content of the .egg-info file introduced into Python
2.5.


  >>> from distutils import get_metadata
  >>> get_metadata('ThePackage')
  {..}

(Working on a prototype)
msg79612 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-01-11 19:07
It looks like the best way to do this is to:

- make distutils.dist.DistributionMetadata also read existing egg-info files

- add get_metadata in pkgutil instead of distutils, and make it use 
  distutils.dist.DistributionMetadata
msg79636 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-01-11 23:52
heres a first simple draft, that works on .egg-info files,

(the Description extractor needs to rework, but this patch is enough to
discuss the feature)
msg79676 - (view) Author: Ray (rayterrill) Date: 2009-01-12 14:28
The patch didn't install correctly using 'patch', but I manually merged
the changes into my environment (Ubuntu 8.10 running 2.5.2) - I'll
upload the diff rejections if they'll be helpful.

After installing, I attempted to use the new code to determine the
version number, and am receiving 'None' as my result.  After looking
through the code, I believe its looking for a '.egg-info' file, but my
custom package doesn't have one (it was installed using 'easy_install' -
easy_install -z <package_name>), so it looks like that info is instead
stored in EGG_INFO/PKG-INFO within the egg itself.

Here's a dir dump of my installed egg:
my_package-1.0-py2.5.egg/
|-- EGG-INFO
|   |-- PKG-INFO
|   |-- SOURCES.txt
|   |-- dependency_links.txt
|   |-- top_level.txt
|   `-- zip-safe
|-- my_package.py
`-- my_package.pyc
msg79677 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-01-12 14:34
yes the patch doesn't treat the eggs installed with easy_install yet,
just plain distutils

I'll let you know when EGG_INFO/PKG-INFO is ready (should be in the
coming days)
msg79679 - (view) Author: Ray (rayterrill) Date: 2009-01-12 14:53
I've tested it out using the straight distutils installation, and it
works great!
msg79718 - (view) Author: Andi Albrecht (aalbrecht) * Date: 2009-01-13 05:15
Is it intended that when reading PKG-INFO files the PEP 314 attributes
(provides, requires, obsoletes) are only set if version is exactly "1.1"? 

I'd expected that those attributes are available regardless of the
metadata version of the parsed file (with None as default for PKG-INFO
files < 1.1).
msg79876 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-01-14 21:04
I have improved the patch (uploaded here) (some cases are not done yet,
still work in progress)

Ray, it should work with egg generated by setuptools now, (zipped as well)

Andi, right ! -> fixed in the current patch
msg80421 - (view) Author: Ray (rayterrill) Date: 2009-01-23 21:38
any chance of getting a patch that would work in 2.4?
msg80439 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-01-24 09:20
Well since Python 2.4 doesn't have the egg-info feature, that is another
story.
msg80465 - (view) Author: Ray (rayterrill) Date: 2009-01-24 17:05
There wouldn't be an easy way to read the distutils setup.py info at
all in 2.4?  i suppose i could write something specific for our
environment.

On 1/24/09, Tarek Ziadé <report@bugs.python.org> wrote:
>
>  Tarek Ziadé <ziade.tarek@gmail.com> added the comment:
>
>  Well since Python 2.4 doesn't have the egg-info feature, that is another
>  story.
>
>
>  _______________________________________
>  Python tracker <report@bugs.python.org>
>  <http://bugs.python.org/issue4908>
>  _______________________________________
>
msg94616 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-10-28 09:19
This patch will be applied for the part that makes DistributionMetadata
load files.

The other part is waiting for PEP 376.
msg102697 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-04-09 08:15
Work done in pkgutil, in the Distutils2 project, see PEP 376 for API names.
msg114513 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-21 16:56
Reversing the duplicate relation with #8250 since this report has more messages.

Not reopening though, since the work is done. Kudos to Josip!
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49158
2010-08-21 16:58:39eric.araujosetresolution: duplicate -> fixed
title: Implement PEP 376 -> Implement pkgutil APIs as described in PEP 376
superseder: Implement pkgutil APIs as described in PEP 376 ->
versions: + Python 2.6, Python 2.5, Python 3.1
2010-08-21 16:56:53eric.araujosetmessages: + msg114513
2010-08-21 16:51:07eric.araujolinkissue8250 superseder
2010-05-26 16:32:00alexissetnosy: + alexis
2010-05-09 21:38:06tareksetstatus: open -> closed
stage: resolved
2010-05-09 21:36:22tareksetresolution: accepted -> duplicate
superseder: Implement pkgutil APIs as described in PEP 376
2010-05-01 01:33:21meatballhatsetnosy: + meatballhat
2010-04-09 08:15:59tareksetnosy: aalbrecht, flub, tarek, eric.araujo, rayterrill
messages: + msg102697
components: + Distutils2, - Distutils
title: adding a get_metadata in distutils -> Implement PEP 376
2010-04-09 00:16:40eric.araujosetnosy: + eric.araujo
2009-10-28 09:19:58tareksetpriority: normal
resolution: accepted
messages: + msg94616

versions: + Python 3.2, - Python 3.1
2009-01-30 13:18:46flubsetnosy: + flub
2009-01-24 17:05:47rayterrillsetmessages: + msg80465
2009-01-24 09:20:09tareksetmessages: + msg80439
2009-01-23 21:38:50rayterrillsetmessages: + msg80421
2009-01-14 21:04:09tareksetmessages: + msg79876
2009-01-14 21:02:28tareksetfiles: - get_metadata.diff
2009-01-14 21:02:14tareksetfiles: + get_metadata.diff
2009-01-13 05:15:16aalbrechtsetnosy: + aalbrecht
messages: + msg79718
2009-01-12 14:53:56rayterrillsetmessages: + msg79679
2009-01-12 14:34:41tareksetmessages: + msg79677
2009-01-12 14:28:57rayterrillsetmessages: + msg79676
2009-01-11 23:52:47tareksetfiles: + get_metadata.diff
keywords: + patch
messages: + msg79636
2009-01-11 19:07:47tareksetmessages: + msg79612
2009-01-10 21:36:50rayterrillsetnosy: + rayterrill
2009-01-10 17:45:04tarekcreate