A different fridge to store your eggs

Today I wanted to release a new version of ImageRepository. For quite some time now, I didn’t update the product pages at plone.org, because it was very time consuming and cumbersome. But recently plone.org was upgraded to a newer Plone version and the PloneSoftwareCenter was updated to a version which supports the PyPI API for egg uploads.

Python 2.6 contains updates which add the mupload and mregister commands to distutils. For older versions, which are still in common use in the Zope/Plone world, there is collective.dist which adds the same commands. After I followed the instructions to update my ~/.pypirc file, I tried to register. Unfortunately by default the egg name is normalized to “products-imagerepository”, but the original location is named just “imagerepository”. I was told by David Glick that there is a tab for distutils settings in the project edit page. After I set the primary distutils id to “Products.ImageRepository”, the mregister command worked fine! Now I just had to remove the download_url setting from setup.py, so there would be no external link created on each registration.

So, after all these steps I finally made a 0.9 release of ImageRepository and it was easily uploaded to both plone.org and PyPI.

Published in: on February 12, 2009 at 4:32 pm  Comments (3)  

Where is that egg?

In the Zope/Plone world working with zc.buildout is the norm nowadays. Many people use an egg cache for speed and disk space preservation. That way eggs aren’t stored directly in your buildout anymore and it can by cumbersome to get there location from the commandline. One way to solve this is collective.recipe.omelette but that only exposes the paths for all eggs at once. I wrote a small shell function to solve that issue.

function eggpath() {
        local name=$1;
        local files=$*;
        if [ -z $files ]; then
                if [ -e ./bin/instance* ]; then
                        local files="$files ./bin/instance*";
                if [ -e ./bin/client* ]; then
                        local files="$files ./bin/client*";
        grep -o -iE "/.*$name.*.egg" $files | sort -u;

With this you can get the path of an egg from any script. First argument is a regexp which is used for matching the name, most of the time this is a simple string with a part of the egg name. Optionally you can provide the name of the script(s) which should be checked, if it’s not given the function will look for bin/instance* or bin/client* scripts by default, which are the most common names for the Zope scripts in Plone buildouts.

My most common use case for this is for opening the egg with my editor like this: mate `eggpath some.egg`.

I hope this is useful for other people as well.

Published in: on February 4, 2009 at 3:56 pm  Comments (1)