[Distutils] Utility to mirror an egg index from a Debian distribution

Brian Sutherland brian at vanguardistas.net
Mon Jun 15 13:10:36 CEST 2009


On Fri, May 15, 2009 at 12:25:31PM -0400, P.J. Eby wrote:
> At 01:00 PM 5/15/2009 +0200, Brian Sutherland wrote:
>> Hi,
>>
>> It may seem like a backwards way of doing things, but I have a need for
>> a utility that can maintain a python package index mirror of a Debian
>> repository.
>>
>> The basic idea is to extract the tarballs of Python packages from the
>> Debian repository and rename them to the original setuptools name. It
>> should also create a buildout-compatible versions file of the versions
>> in the repository.
>>
>> My current implementation idea is to unpack the tarball and use the
>> egg-metadata to figure out what the "egg" name of the tarball should be.
>
> Running "setup.py --name --version" will dump out the name and version, 
> whether you use distutils or setuptools.  If you want a  
> setuptools-compatible name and version, you'll need to postprocess those 
> strings with pkg_resources.safe_name() and safe_version(), then escape 
> them with to_filename() if you're using them as components of a sdist or 
> egg filename.

Thanks, I've just released a prototype:

    http://pypi.python.org/pypi/van.reposync

However, as I did not want to actually execute code contained in the
tarball, I did something like this: 

    basedir = os.path.dirname(egg_info)
    metadata = PathMetadata(basedir, egg_info)
    dist_name = os.path.splitext(os.path.basename(egg_info))[0]
    dist = Distribution(basedir, project_name=dist_name, metadata=metadata)

Unfortunately I had to play some guessing games to find where the
.egg-info directory was.

-- 
Brian Sutherland


More information about the Distutils-SIG mailing list