Mailing List Archive

[issue4908] adding a get_metadata in distutils
New submission from Tarek Ziadé <ziade.tarek@gmail.com>:

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)

----------
assignee: tarek
components: Distutils
messages: 79562
nosy: tarek
severity: normal
status: open
title: adding a get_metadata in distutils
type: feature request
versions: Python 2.7, Python 3.1

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Changes by Ray <rayjohnterrill@gmail.com>:


----------
nosy: +rayterrill

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Tarek Ziadé <ziade.tarek@gmail.com> added the comment:

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

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Tarek Ziadé <ziade.tarek@gmail.com> added the comment:

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)

----------
keywords: +patch
Added file: http://bugs.python.org/file12692/get_metadata.diff

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Ray <rayjohnterrill@gmail.com> added the comment:

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

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Tarek Ziadé <ziade.tarek@gmail.com> added the comment:

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)

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Ray <rayjohnterrill@gmail.com> added the comment:

I've tested it out using the straight distutils installation, and it
works great!

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Andi Albrecht <albrecht.andi@gmail.com> added the comment:

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).

----------
nosy: +aalbrecht

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Changes by Tarek Ziadé <ziade.tarek@gmail.com>:


Added file: http://bugs.python.org/file12746/get_metadata.diff

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Changes by Tarek Ziadé <ziade.tarek@gmail.com>:


Removed file: http://bugs.python.org/file12692/get_metadata.diff

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Tarek Ziadé <ziade.tarek@gmail.com> added the comment:

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

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Ray <rayjohnterrill@gmail.com> added the comment:

any chance of getting a patch that would work in 2.4?

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
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>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Ray <rayjohnterrill@gmail.com> added the comment:

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>
> _______________________________________
>

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue4908] adding a get_metadata in distutils [ In reply to ]
Changes by Floris Bruynooghe <floris.bruynooghe@gmail.com>:


----------
nosy: +flub

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com