[Checkins] SVN: z3c.recipe.depgraph/trunk/ Allow to pass in a ``package-map`` manually, mapping distribution names to different package names.

Hanno Schlichting hannosch at hannosch.eu
Thu Jul 23 05:02:44 EDT 2009


Log message for revision 102121:
  Allow to pass in a ``package-map`` manually, mapping distribution names to different package names.
   
  Added additional ``extras`` option, to control wether or not extra dependencies (like test requirements) should be included.
   
  Corrected distribution name discovery to preserve case.
  

Changed:
  U   z3c.recipe.depgraph/trunk/CHANGES.txt
  U   z3c.recipe.depgraph/trunk/README.txt
  U   z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py
  U   z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py

-=-
Modified: z3c.recipe.depgraph/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.depgraph/trunk/CHANGES.txt	2009-07-23 08:17:58 UTC (rev 102120)
+++ z3c.recipe.depgraph/trunk/CHANGES.txt	2009-07-23 09:02:44 UTC (rev 102121)
@@ -4,9 +4,14 @@
 0.3 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Allow to pass in a ``package-map`` manually, mapping distribution names
+  to different package names.
 
+- Added additional ``extras`` option, to control wether or not extra
+  dependencies (like test requirements) should be included.
 
+- Corrected distribution name discovery to preserve case.
+
 0.2 (2009-05-24)
 ----------------
 

Modified: z3c.recipe.depgraph/trunk/README.txt
===================================================================
--- z3c.recipe.depgraph/trunk/README.txt	2009-07-23 08:17:58 UTC (rev 102120)
+++ z3c.recipe.depgraph/trunk/README.txt	2009-07-23 09:02:44 UTC (rev 102121)
@@ -13,6 +13,14 @@
 exclude
   A list of eggs which should be excluded from the graph processing.
 
+extras
+  A boolean determining if extra requirements should be included. Defaults
+  to False.
+
+package-map
+  An buildout section containing a mapping of distribution names to package
+  names.
+
 variants
   A whitespace separated list of variants of graphs to create. The available
   options are:

Modified: z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py
===================================================================
--- z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py	2009-07-23 08:17:58 UTC (rev 102120)
+++ z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/recipe.py	2009-07-23 09:02:44 UTC (rev 102121)
@@ -26,6 +26,8 @@
         self.output = self.options.get(
             'output', os.path.join(
             self.buildout['buildout']['parts-directory'], self.name))
+        extras = self.options.get('extras', 'false')
+        self.extras = extras.lower() in ('1', 'true', 'yes')
 
     def install(self):
         options = self.options
@@ -38,17 +40,27 @@
         variants = [v.strip() for v in variants.split()]
 
         # Install an interpreter
-        packages = set(ws.by_key.keys()) - EXCLUDE_PACKAGES - self.exclude
+        packages = set([dist.project_name for dist in ws.by_key.values()])
+        packages = packages - EXCLUDE_PACKAGES - self.exclude
         packages = list(packages)
+
+        # Allow to map distribution names to different package names
+        pmap = dict()
+        package_map = options.get('package-map', '').strip()
+        if package_map:
+            pmap = self.buildout[package_map]
         packages.sort()
+
         easy_install.scripts(
             [('graph-%s' % self.name, 'z3c.recipe.depgraph.runner', 'main')],
             ws, options['executable'], options['bin-directory'],
             arguments=dict(
                 packages=packages,
+                package_map=package_map,
                 name=self.name,
                 path=self.output,
-                variants=variants
+                variants=variants,
+                extras=self.extras,
                 ),
             )
 

Modified: z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py
===================================================================
--- z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py	2009-07-23 08:17:58 UTC (rev 102120)
+++ z3c.recipe.depgraph/trunk/src/z3c/recipe/depgraph/runner.py	2009-07-23 09:02:44 UTC (rev 102121)
@@ -1,14 +1,11 @@
 import os
 
-GENERATE = "./bin/%(scriptname)s -x -d %(package)s -i setuptools > %(output)s"
+GENERATE = "./bin/%(scriptname)s %(extras)s-d %(package)s -i setuptools > %(output)s"
 TRED = "tred %(input)s > %(output)s"
 GRAPH = "dot -Tsvg %(input)s > %(output)s"
 SCCMAP = "sccmap %(input)s > %(output)s"
 SCCGRAPH = "dot -Tsvg %(input)s -O"
 
-PACKAGE_EXCEPTIONS = {
-    'Plone' : 'Products.CMFPlone',
-}
 
 def execute(template, **kwargs):
     os.system(template % kwargs)
@@ -17,19 +14,29 @@
 def main(args):
     name = args.get('name')
     packages = args.get('packages')
+    package_map = args.get('package_map')
     path = args.get('path')
     scriptname = name + '-eggdeps'
     variants = args.get('variants', ['base', 'tred', 'scc'])
+    extras = args.get('extras')
 
     for package in packages:
-        package = PACKAGE_EXCEPTIONS.get(package, package)
-        deeppath = os.path.join(path, package.replace('.', os.sep))
+        name = package
+        if name in package_map:
+            name = package_map[name]
+        deeppath = os.path.join(path, name.replace('.', os.sep))
 
         if not os.path.exists(deeppath):
             os.makedirs(deeppath)
 
+        if extras:
+            extras = '-x '
+        else:
+            extras = ''
+
         specfile = os.path.join(deeppath, 'spec')
         execute(GENERATE,
+            extras=extras,
             scriptname=scriptname,
             package=package,
             output=specfile + '.dot')



More information about the Checkins mailing list