Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Last active April 22, 2017 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonflight/6fbf6651195fa6d08242a835577f0715 to your computer and use it in GitHub Desktop.
Save pigeonflight/6fbf6651195fa6d08242a835577f0715 to your computer and use it in GitHub Desktop.
Extract and pin eggs from a buildout instance - Useful for Migration of older Plone buildouts

Background

The extract-eggs-from-instance-and-pin.py script is used as part of migrating old plone sites. This allows me to generate the versions of eggs that are known to work.

It gives you a good starting point, but don't stick to it religiously. You'll find that you may need to remove the zc.buildout and setuptools pins for example.

WARNING! This is a "works for me" script.

Useful tips

I needed to write these down somewhere, and this is as good a place as any. - make sure you have the correct version of Python, if you're using Plone 3.x or less it will be Python 2.4.x (you can build a really robust version of Python 2.4 using buildout.python (just google it)). - copy over eggs from the working buildout into your buildout cache (for example I got an error like this during a migration Error: Couldn't find a distribution for 'GChartWrapper==0.9') - Erros like "Could not install ..." are different from "Couldn't find...: and are sometimes due to network errors, just run buildout again.

Known issues

Pins which have underscores sometimes act weird. For example I got the following error during a migration:

The constraint, 1.0adev_r79583, is not consistent with the requirement, 'Products.MemcachedPageCacheManager==1.0adev-r79583'.

The pinned version included an underscore like this Products.MemcachedPageCacheManager==1.0adev_r79583 so I changed it to a dash like this Products.MemcachedPageCacheManager==1.0adev-r79583.

Usage

It assumes that you have a file called instance in your directory. Edit the script to point to your file.

instance is the generated bin/instance file from a Plone instance.

Using this script you can extract the eggs in a format ready for pinning in a versions.cfg type file.

Usage is basically running the script:

python extract-eggs-from-instance-and-pin.py

Output should look something like:

Products.CMFPlacefulWorkflow=1.4.2
Products.CMFFormController=2.1.2
Products.CMFEditions=1.2.4
Products.CMFDynamicViewFTI=3.0.2
Products.CMFDiffTool=0.5.1
Products.CMFDefault=2.1.2
Products.CMFCore=2.1.2
Products.CMFCalendar=2.1.2
Products.CMFActionIcons=2.1.2
Products.ATContentTypes=1.3.2
Products.ATReferenceBrowserWidget=2.0.4
Products.Archetypes=1.5.11
Products.AdvancedQuery=3.0
Products.kupu=1.4.15
GChartWrapper=0.9
p4a.fileimage=1.0.2
p4a.z2utils=1.0.2
p4a.common=1.0.7
zope.component=3.4.0
feedparser=4.1
python_memcached=1.44
lxml=2.2.2
PasteScript=1.7.3
PasteDeploy=1.3.3
zope.security=3.5.2
plone.autoform=1.0b2
plone.app.z3cform=0.4.5
plone.supermodel=1.0b2
plone.registry=1.0b1
plone.keyring=1.2
python_openid=2.2.4
markdown=1.7
Products.ZopeVersionControl=1.0a1
Products.CMFTestCase=0.9.8
simplejson=2.0.9
Products.validation=1.6.3
Products.Marshall=1.2.1
zope.i18n=3.4.0
python_dateutil=1.5
Paste=1.7.2
zope.location=3.4.0
plone.z3cform=0.5.4
collective.z3cform.datetimewidget=0.1a2
z3c.formwidget.query=0.5
z3c.batching=1.1.0
z3c.form=1.9.0
with open('instance1') as input_file:
for line in input_file:
items = [item.strip() for item in line.split('/')]
egg = items[-1].replace("',","")
if egg.endswith("egg"):
eggparts = egg.split('-')
print "%s=%s" % (eggparts[0],eggparts[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment